結果
| 問題 |
No.1152 10億ゲーム
|
| コンテスト | |
| ユーザー |
LayCurse
|
| 提出日時 | 2020-08-07 22:54:36 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 93 ms / 2,000 ms |
| コード長 | 3,354 bytes |
| コンパイル時間 | 3,033 ms |
| コンパイル使用メモリ | 209,124 KB |
| 最終ジャッジ日時 | 2025-01-12 17:45:00 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 50 |
コンパイルメッセージ
main.cpp: In function ‘void input()’:
main.cpp:18:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
18 | scanf("%d",&x);
| ~~~~~^~~~~~~~~
ソースコード
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S min_L(S a,T b){
return a<=b?a:b;
}
template<class S, class T> inline S max_L(S a,T b){
return a>=b?a:b;
}
int m2;
int m5;
int o2;
int o5;
int in2;
int in5;
void input(void){
int x;
scanf("%d",&x);
in2 = in5 = 0;
while(x%2==0){
in2++;
x/=2;
}
while(x%5==0){
in5++;
x/=5;
}
}
void output(void){
int cTE1_r3A, xr20shxY;
int x = 1;
for(cTE1_r3A=(0);cTE1_r3A<(m2);cTE1_r3A++){
x *= 2;
}
for(xr20shxY=(0);xr20shxY<(m5);xr20shxY++){
x *= 5;
}
printf("%d\n",x);
fflush(stdout);
}
int main(){
int mn;
int mx;
int fg = 0;
input();
{
auto KrdatlYV = (in2);
auto ao_dF3pO = ( in5);
m2 = KrdatlYV;
m5 = ao_dF3pO;
}
input();
{
auto tU__gIr_ = (in2);
auto a2conNHc = ( in5);
o2 = tU__gIr_;
o5 = a2conNHc;
}
for(;;){
if( (m2+m5+o2+o5)%2 == 0 ){
mn =min_L(m2, m5);
if(m2==7 && m5==9){
m2 = m5 = 9;
}
else if(mn < 7 && m2==mn){
m2++;
}
else if(mn < 7 && m5==mn){
m5++;
}
else if(m2 > 7){
m2--;
}
else{
m5++;
}
output();
if(m2==o2 && m5==o5){
return 0;
}
input();
{
auto YREPHmFM = (in2);
auto jZyWAPpY = ( in5);
o2 = YREPHmFM;
o5 = jZyWAPpY;
}
if(m2==o2 && m5==o5){
return 0;
}
continue;
}
mx =max_L(abs(m2-o2), abs(m5-o5));
if(m2+mx==o2){
m2++;
}
else if(m2-mx==o2){
m2--;
}
else if(m5+mx==o5){
m5++;
}
else{
m5--;
}
output();
if(m2==o2 && m5==o5){
return 0;
}
input();
{
auto ZIeRIny5 = (in2);
auto iMWUTgY_ = ( in5);
o2 = ZIeRIny5;
o5 = iMWUTgY_;
}
if(m2==o2 && m5==o5){
return 0;
}
continue;
}
return 0;
}
// cLay varsion 20200509-1
// --- original code ---
// int m2, m5, o2, o5;
//
// int in2, in5;
// void input(void){
// int x;
// scanf("%d",&x);
// in2 = in5 = 0;
// while(x%2==0) in2++, x/=2;
// while(x%5==0) in5++, x/=5;
// }
//
// void output(void){
// int x = 1;
// rep(m2) x *= 2;
// rep(m5) x *= 5;
// printf("%d\n",x);
// fflush(stdout);
// }
//
//
// {
// int mn, mx, fg = 0;
//
// input();
// (m2, m5) = (in2, in5);
// input();
// (o2, o5) = (in2, in5);
//
// for(;;){
// if( (m2+m5+o2+o5)%2 == 0 ){
// mn = min(m2, m5);
// if(m2==7 && m5==9){
// m2 = m5 = 9;
// } else if(mn < 7 && m2==mn){
// m2++;
// } else if(mn < 7 && m5==mn){
// m5++;
// } else if(m2 > 7){
// m2--;
// } else {
// m5++;
// }
// output();
// if(m2==o2 && m5==o5) return 0;
// input();
// (o2, o5) = (in2, in5);
// if(m2==o2 && m5==o5) return 0;
// continue;
// }
//
// mx = max(abs(m2-o2), abs(m5-o5));
// if(m2+mx==o2){
// m2++;
// } else if(m2-mx==o2){
// m2--;
// } else if(m5+mx==o5){
// m5++;
// } else {
// m5--;
// }
// output();
// if(m2==o2 && m5==o5) return 0;
// input();
// (o2, o5) = (in2, in5);
// if(m2==o2 && m5==o5) return 0;
// continue;
// }
// }
LayCurse