結果

問題 No.1486 ロボット
ユーザー kaede2020kaede2020
提出日時 2021-04-24 07:46:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 1,579 bytes
コンパイル時間 3,787 ms
コンパイル使用メモリ 225,896 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-17 13:30:01
合計ジャッジ時間 4,520 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 16 ms
4,380 KB
testcase_07 AC 17 ms
4,376 KB
testcase_08 AC 9 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 9 ms
4,376 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 4 ms
4,376 KB
testcase_17 AC 5 ms
4,376 KB
testcase_18 AC 4 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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){
    if(cnt==x)break;
    if(cnt%(a+b)<a)hantei1=true;
    else hantei1=false;
    if(cnt%(c+d)<c)hantei2=true;
    else hantei2=false;
    cnt++;
    if(hantei1==true&&hantei2==true)moto++;
    //cout<<cnt<<" "<<hantei1<<" "<<hantei2<<" "<<moto<<endl;
  }
  if(e>=x){
    ans+=moto*(e/x);
    e-=x*(e/x);
    //cout<<ans<<" "<<moto<<" "<<e<<endl;
  }
  cnt=0;
  hantei1=true;
  hantei2=true;
  r1=0,r2=0,r1_yasumi=0,r2_yasumi=0;
  while(e>cnt){
    if(cnt==e)break;
    if(cnt%(a+b)<a)hantei1=true;
    else hantei1=false;
    if(cnt%(c+d)<c)hantei2=true;
    else hantei2=false;
    //cout<<cnt<<" "<<hantei1<<" "<<hantei2<<endl;
    if(hantei1==true&&hantei2==true)ans++;
    cnt++;
  }
  cout<<ans<<endl;
  return 0;
}
0