2014-03-27 Code 備忘錄►Math HOJ::Problem : 7 - 微波爐 http://hoj.twbbs.org.tw/judge/problem/view/7觀察題目。 其實是費氏數列,因為牽手的狀態是前兩個人的狀態(如果和上一個牽手)加上前一個人的狀態(如果不牽手)和。 12345678910111213141516#include <cstdlib>#include <iostream>using namespace std;int main(int argc,char *argv[]){ ios_base::sync_with_stdio(false); int n,tmp1=0,tmp2=1; cin>>n; for(int i=0;i<n;i++){ tmp1=tmp1+tmp2; tmp1%=10; int ch=tmp1;tmp1=tmp2;tmp2=ch; } cout<<tmp2<<endl; return 0;} Newer HOJ::Problem : 9 - 大麥克的世界旅行 Older HOJ::Problem : 192 - 撿肥皂