Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
哪里错了,狂WA不止#include <iostream> using namespace std; const int N = 100000; char s[N]; int s1[N]; bool f(int a, int b) { return a * 10 + b < 27; } int main() { double a[N]; int i, j; while(cin>>s, s[0] != '0' ) { for(i=j=0; s[i]; i++) { if(s[i] != '0') s1[j++] = s[i] - '0'; else s1[j - 1] *= 10; } if ( j == 1) { puts("1"); continue; } a[0] = 1; if(s1[0] <10 && f(s1[0], s1[1]) ) a[1] = 2; else a[1] = 1; for(i=2; i<j; i++) { a[i] = a[i-1]; if(s1[i] < 10 && f( s1[i-1], s1[i]) ) a[i] += a[i-2]; } printf("%.0lf\n", a[i-1]); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator