HDOJ_2046_骨牌方格_大二寫
阿新 • • 發佈:2018-11-09
AC程式碼:
#include <iostream> #include <cstdio> #include <cstdlib> using namespace std; int main(void) { freopen("in.txt","r",stdin); int n; while(scanf("%d",&n)!=EOF) { long long int count,count1,count2; for(int i=1;i<=n;i++) {if(i==1) { count1 = 1; count = count1; } else if(i==2) { count2 = 2; count = count2; } else { count = count1 + count2; count1= count2; count2 = count; } } printf("%lld\n",count); } fclose(stdin); system("pause"); return 0; }