nyoj_532_http://acm.nyist.net/JudgeOnline/problem.php?pid=532
来源:互联网 发布:批量修改图片的软件 编辑:程序博客网 时间:2024/06/07 16:40
题目来源:http://acm.nyist.net/JudgeOnline/problem.php?pid=532
关于这种数学题,其实还是需要多加训练的。做的多了头脑就灵活了。额!其实这道题也不算太难啦!下面分享一下吧!
主要就是sum函数中的那点代码,如果你看懂了。恭喜你,此题已成小菜!看不懂,没关系,自己找几个大点的测试数据,来调试一番,自己推理一下!Understand!
#include<iostream>
using namespace std;
int res;
int sum(int x,int y)
{
int i,k=1;
for(i=0;i<y;i++)
k*=9;
return k*x;
}
bool flag(int y)
{
int x,z=0;
while(y)
{
x=y%10;
y=y/10;
if(x==0)
return false;
res+=sum(x,z);z++;
}
return true;
}
int main()
{
int n;
while(cin>>n)
{
res=0;
if(n==0||!flag(n))
cout<<"Unlucky"<<endl;
else
cout<<res<<endl;
}
return 0;
}
- nyoj_532_http://acm.nyist.net/JudgeOnline/problem.php?pid=532
- http://acm.nyist.net/JudgeOnline/problem.php?pid=290
- http://acm.nyist.net/JudgeOnline/problem.php?pid=434
- http://acm.nyist.net/JudgeOnline/problem.php?pid=13
- http://acm.nyist.net/JudgeOnline/problem.php?pid=239
- http://acm.nyist.net/JudgeOnline/problem.php?pid=129
- http://acm.nyist.net/JudgeOnline/problem.php?pid=431
- http://acm.nyist.net/JudgeOnline/problem.php?pid=301
- http://acm.nyist.net/JudgeOnline/problem.php?pid=451
- http://acm.nyist.net/JudgeOnline/problem.php?pid=459
- http://acm.nyist.net/JudgeOnline/problem.php?pid=20
- http://acm.nyist.net/JudgeOnline/problem.php?pid=267
- http://acm.nyist.net/JudgeOnline/problem.php?pid=305
- http://acm.nyist.net/JudgeOnline/problem.php?pid=309
- http://acm.nyist.net/JudgeOnline/problem.php?pid=325
- http://acm.nyist.net/JudgeOnline/problem.php?pid=420
- http://acm.nyist.net/JudgeOnline/problem.php?pid=488
- http://acm.nyist.net/JudgeOnline/problem.php?pid=150
- 黑马程序员--委托与事件的初步学习
- MyEclipse使用经验总结
- vsftpd设置的详解
- 如何在ECLIPSE中安装SVN插件
- 一步一步写算法(之哈夫曼编码)
- nyoj_532_http://acm.nyist.net/JudgeOnline/problem.php?pid=532
- BF算法
- Hadoop安装笔记
- Square Coins
- Java中用split函数进行分割字符串。
- 大师的风采
- JSP 通过Servlet将excel数据导入SQL
- 第十二周实验报告1
- Knight Moves