社区讨论

60分玄关求助

P1149[NOIP 2008 提高组] 火柴棒等式参与者 2已保存回复 4

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
4 条
当前快照
1 份
快照标识符
@lyqzwcie
此快照首次捕获于
2024/07/18 16:14
2 年前
此快照最后确认于
2024/07/18 16:49
2 年前
查看原帖
CPP
#include<bits/stdc++.h>
using namespace std;
int a[10]={6,2,5,5,4,5,6,3,7,6};
int n,b,c,s;
int pcm(int f){
    int s1=0;
    while(f>0){
        s1+=a[f%10];
        f/=10;
    }
    return s1; 
}
bool bcm(int w,int x,int y,int e){
    int s2=0;
    s2+=pcm(w);
    s2+=pcm(x);
    s2+=pcm(y);
    if(s2==e)
        return true;
    return false;
}
int main(){
    cin>>n;
    n-=4;
    for(int i=0;i<1000;i++)
        for(int j=0;j<1000;j++) 
            if(bcm(i,j,i+j,n))
                    s++; 
    cout<<s; 
    return 0;
}

回复

4 条回复,欢迎继续交流。

正在加载回复...