結果
| 問題 |
No.2 素因数ゲーム
|
| コンテスト | |
| ユーザー |
goodbaton
|
| 提出日時 | 2015-07-15 23:04:44 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 1,772 bytes |
| コンパイル時間 | 1,291 ms |
| コンパイル使用メモリ | 89,632 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-26 11:35:41 |
| 合計ジャッジ時間 | 2,327 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 31 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:82:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
82 | scanf("%d",&n);
| ~~~~~^~~~~~~~~
ソースコード
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
typedef long long ll;
using namespace std;
#define mod 1000000007
#define INF 1000000000
#define LLINF 2000000000000000000LL
#define SIZE 200000
int n;
vector<pair<int,int> > pf;
map<int,int> dp;
int cc[30]={0};
int ans=0;
void dfs(int h,int a){
if(h==(int)pf.size()){
if(a==1)
return;
vector<int> vec;
int c = 0;
for(int i=0;i<h;i++){
int b = a;
for(int j=1;j<=cc[i];j++){
b/=pf[i].first;
vec.push_back(dp[b]);
}
}
sort(vec.begin(),vec.end());
if(vec[0]>0){
dp[a]=0;
ans^=0;
return;
}
while(c<vec.size()-1){
if(vec[c]+1>=vec[c+1])
c++;
else
break;
}
dp[a]=vec[c]+1;
ans^=vec[c]+1;
return;
}
cc[h]=0;
dfs(h+1, a);
for(int i=0;i<pf[h].second;i++){
cc[h]=i+1;
a*=pf[h].first;
dfs(h+1,a);
}
}
int main(){
scanf("%d",&n);
int N = n;
for(int i=2;i*i<=n;i++){
int c=0;
while(n%i==0){
c++;
n/=i;
}
if(c>0)
pf.push_back(make_pair(i, c));
}
if(n>1)
pf.push_back(make_pair(n, 1));
dp[1]=0;
dfs(0,1);
if(dp[N]==0)
puts("Bob");
else
puts("Alice");
return 0;
}
goodbaton