結果
問題 | No.344 ある無理数の累乗 |
ユーザー |
|
提出日時 | 2016-02-13 01:11:07 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 808 bytes |
コンパイル時間 | 1,317 ms |
コンパイル使用メモリ | 167,200 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 05:22:39 |
合計ジャッジ時間 | 2,236 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long ll;#define rep(i,n) for(i=0;i<n;++i)#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)#define mp make_pair#define pb push_back#define fi first#define sc secondint main(int argc, char const *argv[]) {long i;long n;cin >>n;//h_n-1とh_n-2を保存set<pair<int,int>> s;std::vector<int> h;//初期化h.pb(2);h.pb(2);s.insert(mp(2,2));int a=2,b=2;while(1){int c=(2*a+2*b)%1000;h.pb(c);if(s.find(mp(b,c))==s.end()){//printf(" in %4d %4d\n",b,c);s.insert(mp(b,c));}else break;a=b;b=c;}int ans;if(n<4) ans=h[n];else ans=h[4+(n-4)%600];if(n%2==0) ans=(ans-1+1000)%1000;printf("%d\n",ans);return 0;}