【NOIP2008】【Luogu1149】火柴棒等式
【摘要】
problem
solution
codes
#include<iostream>
using namespace std;
int num(int x){
int s[11] ...
problem
solution
codes
#include<iostream>
using namespace std;
int num(int x){
int s[11] = {6,2,5,5,4,5,6,3,7,6};
if(x == 0)return s[0];
int ans = 0;
while(x != 0){
ans += s[x%10];
x /= 10;
}
return ans;
}
int main(){
int n, ans=0;
cin>>n;
for(int i = 0; i < 1000; i++)
for(int j = 0; j < 1000; j++)
if(num(i)+num(j)+num(i+j)+4 == n)
ans++;
cout<<ans;
return 0;
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
#include<iostream>
using namespace std;
int num[11] = {6,2,5,5,4,5,6,3,7,6};
int main(){
int n, ans = 0; cin>>n;
for(int i = 0; i < 1000; i++){
for(int j = 0; j < 1000; j++){
int a = i, b = j, c = i+j, t = 0;
if(a == 0)t += num[0];
if(b == 0)t += num[0];
if(c == 0)t += num[0];
while(a){
t += num[a%10];
a /= 10;
}
while(b){
t += num[b%10];
b /= 10;
}
while(c){
t += num[c%10];
c /= 10;
}
if(t == n-4) ans++;
}
}
cout<<ans<<"\n";
return 0;
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
文章来源: gwj1314.blog.csdn.net,作者:小哈里,版权归原作者所有,如需转载,请联系作者。
原文链接:gwj1314.blog.csdn.net/article/details/80450456
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)