結果
| 問題 |
No.249 N言っちゃダメゲーム (2)
|
| コンテスト | |
| ユーザー |
ty70
|
| 提出日時 | 2015-12-14 03:39:28 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 1,033 bytes |
| コンパイル時間 | 689 ms |
| コンパイル使用メモリ | 57,052 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-15 12:10:25 |
| 合計ジャッジ時間 | 1,098 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 |
ソースコード
#include <iostream>
#include <cstring> // require memset
#include <algorithm> // require sort next_permutation count __gcd reverse etc.
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
using namespace std;
typedef long long ll;
bool is_win(int n, int k){
return (n - 1) % (k + 1) != 0; // 先攻が勝つ true 後攻が勝つ false
}
int n[1000], k[1000];
bool game[1000]; // 先攻が勝利する true 敗退する false
bool res[1000];
int main()
{
memset (n, 0, sizeof(n));
memset (k, 0, sizeof(k));
memset (game, false, sizeof(game));
memset (res, false, sizeof(res));
ios_base::sync_with_stdio(0);
rep (i, 1000){
cin >> n[i] >> k[i];
game[i] = is_win(n[i],k[i]);
} // end rep
bool batting_first = true;
res[0] = game[0];
for (int i = 1; i < 1000; ++i){
if (!res[i-1]){
batting_first = game[i];
}else{
batting_first = !game[i];
} // end if
res[i] = !(batting_first ^ game[i]);
} // end for
int ans = count(res, res+1000, true);
cout << ans << endl;
return 0;
}
ty70