回复 37楼 azzbcc
成功了,上面不成功好像是用了c99mode程序代码:
#include <stdio.h> #define S(a) sizeof (a) #define Max 10000 typedef struct Node { int time1; int time2; }Node; Node Count[Max+1]={0}; int main() { int a[]={2,3,4,5,6,7,8,9}; int n=S(a)/S(int); int N=8; int i=0; int sum=0; int flag=0; int SS=1; if ((a[0]%=N)==0) flag=1; for (;i<n-1&&flag==0;i++) { a[i+1]=(a[i+1]+a[i])%N; if (a[i+1]==0) { SS=i+2; flag=1; break; } } for (i=0;i<n&&flag==0;i++) { if (Count[a[i]].time1==0) Count[a[i]].time1=i+1; else if (Count[a[i]].time2==0) Count[a[i]].time2=i+1; } if (flag) printf("%d\n1\n",SS); for (i=1;i<n+1&&flag==0;i++) if (Count[a[i-1]].time2) { printf("%d\n%d\n",Count[a[i-1]].time2-Count[a[i-1]].time1,i+1); break; } if (i==n+1) printf("No Solution\n"); return 0; }