結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー kapo
提出日時 2016-05-11 04:40:01
言語 C90
(gcc 12.3.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,036 bytes
コンパイル時間 341 ms
コンパイル使用メモリ 22,272 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-06 18:15:40
合計ジャッジ時間 1,727 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 31 WA * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:57:26: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘ll’ {aka ‘long long int’} [-Wformat=]
   57 |                 printf("%d\n", n);
      |                         ~^     ~
      |                          |     |
      |                          int   ll {aka long long int}
      |                         %lld
main.c:54:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   54 |         scanf("%lld %lld %lld %lld", &n, &a, &b, &c);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #
プレゼンテーションモードにする

#include <stdio.h>
typedef long long ll;
ll calc(ll x, ll y)
{
if( y == 0 ) return x;
return calc( y, x%y );
}
ll calc2(ll x, ll y)
{
ll z = calc( y, x%y );
return (x/z) * (y/z) * z;
}
ll calc3(ll x, ll y, ll z)
{
int i, c=1, cnt=1;
while( cnt ) {
cnt=0;
for( i = 2; i <= x; i++) {
if( !(x%i) && !(y%i) && !(z%i) ) {
c *= i;
x /= i; y /= i; z /= i;
cnt++;
}
}
}
for( i = 2; i <= x; i++) {
if( !(x%i) && !(y%i) ) {
c *= i;
x /= i; y /= i;
}
}
for( i = 2; i <= x; i++) {
if( !(x%i) && !(z%i) ) {
c *= i;
x /= i; z /= i;
}
}
for( i = 2; i <= y; i++) {
if( !(y%i) && !(z%i) ) {
c *= i;
y /= i; z /= i;
}
}
return c*x*y*z;
}
int main(void)
{
ll i, n, a, b, c, ab, bc, ac, abc, cnt=0;
scanf("%lld %lld %lld %lld", &n, &a, &b, &c);
if( a == 1 || b == 1 || c == 1 ){
printf("%d\n", n);
return 0;
}
ab = calc2(b, a);
bc = calc2(c, b);
ac = calc2(c, a);
abc = calc3(a, b, c);
printf("%lld\n", (n/a)+(n/b)+(n/c)-(n/ab)-(n/bc)-(n/ac)+(n/abc) );
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0