#include<stdio.h>
long f(__int64 n)
{
while(n!=0){
if(n%10==7)return 1;
n/=10;
}
return 0;
}
int main()
{
static __int64 a[1000000],n,m,i,j=0,f1;
for(i=7;i<1000000000;i++){
if(f(i)||i%7==0)
a[j]++;
else {
f1=1;
for(int k=0;k<j;k++)
if(a[j]<=a[k])f1=0;
if(f1){printf("p=%I64d,x=%I64d\n",a[j],i-a[j]);
j++;}
else a[j]=0;
}
}
}
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3318比赛时没有想到,就是靠人脑举例,导致考虑不完整,出现很多错误!后来经高人指点,编学了个辅助程序,终于ac了!
O(∩_∩)O~,看来还是要好好利用电脑!!
主程序:
#include<stdio.h>
int main()
{
long n,t;
scanf("%d",&t);
while(t--){
scanf("%d",&n);
if(n==1)printf("7\n");
else if(n==2)printf("27\n");
else if(n<=10)printf("70\n");
else if(n<=11)printf("270\n");
else if(n<=100)printf("700\n");
else if(n<=101)printf("2700\n");
else if(n<=1000)printf("7000\n");
else if(n<=1002)printf("26999\n");
else if(n<=10000)printf("70000\n");
else if(n<=10001)printf("270000\n");
else if(n<=100000)printf("700000\n");
else if(n<=100001)printf("1699999\n");
else if(n<=1000000)printf("7000000\n");
else if(n<=1000001)printf("27000000\n");
else if(n<=10000000)printf("70000000\n");
else if(n<=10000001)printf("270000000\n");
else printf("700000000\n");
}
}
posted on 2009-05-04 22:14
zhoubaozhong 阅读(431)
评论(0) 编辑 收藏 引用