結果
| 問題 |
No.1486 ロボット
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-04-24 07:22:19 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,051 bytes |
| コンパイル時間 | 3,505 ms |
| コンパイル使用メモリ | 228,568 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-04 09:00:23 |
| 合計ジャッジ時間 | 4,169 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 4 WA * 13 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using mint = modint1000000007;
//using mint = modint998244353;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef pair<ll, int> P;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
//Google出力用
void Case(int i,char a,int j){ printf("Case #%d: %c %d\n",i,a,j); }
int main(){
ll a,b,c,d,e;
cin>>a>>b>>c>>d>>e;
ll x=lcm(a+b,c+d);
ll moto=0;
ll ans=0;
ll cnt=0;
ll r1=0,r2=0,r1_yasumi=0,r2_yasumi=0;
bool hantei1=true;
bool hantei2=true;
while(x>cnt){
cnt++;
if(hantei1==true&&hantei2==true)moto++;
if(cnt>=x)break;
//cout<<cnt<<" "<<hantei1<<" "<<hantei2<<endl;
if(hantei1){
r1++;
if(r1==a){
hantei1=false;
r1=0;
}
}else{
r1_yasumi++;
if(r1_yasumi==b){
hantei1=true;
r1_yasumi=0;
}
}
if(hantei2){
r2++;
if(r2==c){
hantei2=false;
r2=0;
}
}else{
r2_yasumi++;
if(r2_yasumi==d){
hantei2=true;
r2_yasumi=0;
}
}
}
if(e>x){
ans+=moto*e/x;
e-=x*e/x;
}
cnt=0;
hantei1=true;
hantei2=true;
r1=0,r2=0,r1_yasumi=0,r2_yasumi=0;
while(e>cnt){
cnt++;
if(hantei1==true&&hantei2==true)moto++;
if(cnt>=e)break;
if(hantei1){
r1++;
if(r1==a){
hantei1=false;
r1=0;
}
}else{
r1_yasumi++;
if(r1_yasumi==b){
hantei1=true;
r1_yasumi=0;
}
}
if(hantei2){
r2++;
if(r2==c){
hantei2=false;
r2=0;
}
}else{
r2_yasumi++;
if(r2_yasumi==d){
hantei2=true;
r2_yasumi=0;
}
}
}
cout<<ans<<endl;
return 0;
}