萌新蒟蒻在线求助

P1149 [NOIP2008 提高组] 火柴棒等式

刘明
by Leap_Frog @ 2019-06-30 20:39:42


火钳刘明
by 1saunoya @ 2019-06-30 20:58:13


#include<bits/stdc++.h> using namespace std; int main() { int a[2001]={6},b,c[10]={6,2,5,5,4,5,6,3,7,6},s=0,i,j; scanf("%d",&b); for(i=1;i<=2000;i++) { j=i; while(j>=1) { a[i]=a[i]+c[j%10]; j=j/10; } } for(i=0;i<=1000;i++) { for(j=0;j<=1000;j++) if(a[i]+a[j]+a[i+j]+4==b)s++; } printf("%d",s); return 0; } ------------ 如此,把数一个一个列出来
by FOREIGN @ 2019-07-03 22:25:21


@[PIG集团总经理](/space/show?uid=65597) i和x在上方int,像这样 ------------ #include <iostream> using namespace std; int main(){ int i; int x; int n; int match[10] = {6,2,5,5,4,5,6,3,7,6}; int ans=0; int num[2001]; cin>>n; for(i=0;i<=2000;i++){ x=i; num[i] = 0; while(x!=0){ num[i]+=match[x%10]; x/=10; } } num[0] = 6; n-=4; for(int i=0;i<=2000;i++){ for(int j=0;j<=2000;j++){ if(num[i]+num[j]+num[i+j]==n){ ans++; } } } cout<<ans; return 0; } 帮你改了下程序
by FOREIGN @ 2019-07-03 22:28:53


@[レム、㍕](/space/show?uid=200467) 谢谢大佬,改完了
by PIG集团总经理 @ 2019-07-05 18:18:10


|