結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー itezpaceitezpace
提出日時 2016-09-08 09:12:13
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,123 bytes
コンパイル時間 549 ms
コンパイル使用メモリ 64,636 KB
実行使用メモリ 256,548 KB
最終ジャッジ日時 2024-04-27 17:56:18
合計ジャッジ時間 3,013 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
6,940 KB
testcase_03 WA -
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <set>
using namespace std;
int main(){
  int n,a,b,c;
  cin>>n;
  cin>>a>>b>>c;
  int d=0;
  if(c%b==0){
    c=1e9+1;
    d+=1;
  }
  if(b%a==0){
    b=1e9+1;
    d+=1;
  }
  int x=n/a+n/b+n/c;
  set<int> s;
  int ab=1e9+1;
  if(b!=1e9+1){
  if(b%a!=0){
    ab=a*b;
  } else {
    ab=b;
  }
  }
  int ac=1e9+1;
  if(c!=1e9+1){
  if(c%a!=0){
    ac=a*c;
  } else {
    ac=c;
  }
  }
  int bc=1e9+1;
  if(b!=1e9+1 && c!=1e9+1){
  if(c%b!=0){
    bc=b*c;
  } else {
    bc=c;
  }
  }
  int abc=1e9+1;
  if(a!=1e9+1 && b!=1e9+1 && c!=1e9+1){
  if(b%a!=0 && c%b!=0){
    abc=a*b*c;
  } else if(b%a!=0 && c%b==0){
    abc=a*c;
  } else if(b%a==0 && c%b!=0){
    abc=b*c;
  } else {
    abc=c;
  }
  }
  int nab=n/ab;
  int nac=n/ac;
  int nbc=n/bc;
  int nabc=n/abc;
  for(int i=1; i<=nab; ++i){
    int y=ab*i;
    s.insert(y);
  }
  for(int i=1; i<=nac; ++i){
    int y=ac*i;
    s.insert(y);
  }
  for(int i=1; i<=nbc; ++i){
    int y=bc*i;
    s.insert(y);
  }
  for(int i=1; i<=nabc; ++i){
    int y=abc*i;
    s.insert(y);
  }
  int z=x-s.size();
  if(d<1) z-=3;
  cout<<z<<endl;
  return 0;
}
0