POJ 2196 & ZOJ 2405 & UVA 3199
2017-07-03 14:53
441 查看
思路:进制转换,使用辗转相除法,由于只需要求和,因此不需要考虑余数逆序,直接相加即可
#include<iostream>
using namespace std;
int systemSum(int x, int base)
{
int sum = 0;
while(x){
sum += (x % base);
x /= base;
}
return sum;
}
int main()
{
for(int i = 1000 ; i < 10000; i++)
if(systemSum(i,10) == systemSum(i,12) && systemSum(i,10) == systemSum(i,16))
cout << i << endl;
}
#include<iostream>
using namespace std;
int systemSum(int x, int base)
{
int sum = 0;
while(x){
sum += (x % base);
x /= base;
}
return sum;
}
int main()
{
for(int i = 1000 ; i < 10000; i++)
if(systemSum(i,10) == systemSum(i,12) && systemSum(i,10) == systemSum(i,16))
cout << i << endl;
}
相关文章推荐
- hdu 4071& poj 3873 & zoj 3386 & uva 12197 Trick or Treat 三分法
- UVa 714 & POJ 1505 & ZOJ 2002 - Copying Books
- POJ 2149 & ZOJ 2267&UVA 1337&UVALive 3192 Inherit the Spheres
- POJ 1903 & ZOJ 2469 & UVA 1326 Jurassic Remains (部分枚举)
- POJ 1903 & ZOJ 2469 & UVA 1326 Jurassic Remains (部分枚举)
- POJ 1005 & ZOJ 1049 & UVA 2363
- UVa 10714 & POJ 1852 & ZOJ 2376 - Ants
- UVa 439/HDU 1372/POJ 2243/ZOJ 1091 Knight Moves(BFS&纯数学方法)
- zoj 2016 && poj 1386 && uva 10129 Play on Words
- zoj 1377 || poj 1228 Grandpa's Estate
- poj 1637 & zoj 1992 混合图的欧拉回路
- poj 2029 && zoj 1716 Get Many Persimmon Trees
- poj 2063& zoj 2224 Investment (多次完全背包)
- zoj 1031& poj 1084 (Dancing Links 重复覆盖)
- zoj 1886 || poj 2540 || UVA 10084 Hotter Colder
- 【图染色】POJ 1419 & UVA 193
- ZOJ 1857 && POJ 2607 Fire Station【SPFA】
- ZOJ 1133 & POJ 1142 Smith Numbers
- poj 1014 & zoj 1149 Dividing(多重背包+倍增思想优化)
- poj 3268 Silver Cow Party & zoj 2008 Invitation Cards