竞赛
考级
#include <bits/stdc++.h> using namespace std; int main(){ int n; scanf("%d",&n); string A="4567",B="123",C="1234567"; while(C.size()<n) { A=B; B=C; C=B+A; } cout<<C[n-1]<<endl; return 0; }
Voldemort
#include<iostream> #include<cstring> using namespace std; int main(){ int n; cin >> n; string a,b,c; b = "123"; a = "4567"; c = b+a; while(c.size()<n){ a = b; b = c; c = b + a; } cout << c[n-1]; return 0; }
T0
共23条