結果

問題 No.1004 サイコロの実装 (2)
ユーザー kikagekikage
提出日時 2020-04-10 23:09:54
言語 C++11
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 468 bytes
コンパイル時間 853 ms
コンパイル使用メモリ 22,784 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-09-16 00:01:45
合計ジャッジ時間 4,934 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 24 TLE * 1 -- * 13
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:4:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    4 |     scanf("%d %d %d %d",&a,&b,&x,&N);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <cstdio>
int main(){
    unsigned int a,b,x,N;
    scanf("%d %d %d %d",&a,&b,&x,&N);
    int tw=0,tb=0,aw=0,ab=0;
    for(int i=0,pt=0,pa=0;i<N;i++){
        x=a*x+b;
        if(!(x&1))pt=1-pt;
        if(pt) tb++; 
        else tw++;
        x=a*x+b;
        if(!(x&1))pa=1-pa;
        if(pa) ab++; 
        else aw++;
    }
    if(tw<tb)printf("%d ",tw);
    else printf("%d ",tb);
    if(aw<ab)printf("%d\n",aw);
    else printf("%d\n",ab);
    return 0;
}
0