結果
問題 | No.316 もっと刺激的なFizzBuzzをください |
ユーザー |
|
提出日時 | 2018-04-05 00:10:08 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 1,000 ms |
コード長 | 397 bytes |
コンパイル時間 | 210 ms |
コンパイル使用メモリ | 22,912 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-26 08:59:05 |
合計ジャッジ時間 | 1,266 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:12:9: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | scanf("%lld %lld %lld %lld", &N, &a, &b, &c); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>typedef long long ll;ll gcd(ll a, ll b){if( b > a){ ll tmp = b; b = a; a = tmp;}ll amari;while( ( amari = a % b ) != 0 ){ a = b; b = amari; }return b;}ll lcm(ll a, ll b){ return a / gcd(a,b) * b;}int main(){ll N,a,b,c;scanf("%lld %lld %lld %lld", &N, &a, &b, &c);printf("%lld\n", N/a+N/b+N/c-N/lcm(a,b)-N/lcm(b,c)-N/lcm(c,a)+N/lcm(a,lcm(b,c)));}