結果

問題 No.1486 ロボット
ユーザー 👑 CleyL
提出日時 2022-11-07 13:32:47
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 407 bytes
コンパイル時間 600 ms
コンパイル使用メモリ 66,400 KB
最終ジャッジ日時 2025-02-08 19:08:14
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

int gcd(int a,int b){
  if(a%b)return gcd(b,a%b);
  else return b;
}

int lcm(int a,int b){
  return a*b/gcd(a,b);
}

int main(){
  int a,b,c,d,e;cin>>a>>b>>c>>d>>e;
  int x = lcm(a+b,c+d);
  int ans = 0;
  int lp = 0;
  for(int i = 0; x > i; i++){
    if(i%(a+b) < a && i%(c+d) < c){
      if(i < e%x)ans++;
      lp++;
    }
  }
  cout << ans+lp*(e/x) << endl;
}
0