結果

問題 No.2156 ぞい文字列
ユーザー tailstails
提出日時 2023-01-26 18:17:03
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 1,782 bytes
コンパイル時間 137 ms
コンパイル使用メモリ 22,656 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-27 10:47:24
合計ジャッジ時間 939 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
5,248 KB
testcase_01 AC 0 ms
5,376 KB
testcase_02 AC 0 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 0 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 0 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 0 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:71:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
   71 | main(){
      | ^~~~
main.c: In function ‘main’:
main.c:73:9: warning: implicit declaration of function ‘scanf’ [-Wimplicit-function-declaration]
   73 |         scanf("%lu",&n);
      |         ^~~~~
main.c:1:1: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’
  +++ |+#include <stdio.h>
    1 | #pragma GCC optimize("Ofast")
main.c:73:9: warning: incompatible implicit declaration of built-in function ‘scanf’ [-Wbuiltin-declaration-mismatch]
   73 |         scanf("%lu",&n);
      |         ^~~~~
main.c:73:9: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’
main.c:84:9: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]
   84 |         printf("%d",(x0+MD-1)%MD);
      |         ^~~~~~
main.c:84:9: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
main.c:84:9: warning: incompatible implicit declaration of built-in function ‘printf’ [-Wbuiltin-declaration-mismatch]
main.c:84:9: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
main.c:84:18: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long unsigned int’ [-Wformat=]
   84 |         printf("%d",(x0+MD-1)%MD);
      |                 ~^
      |                  |
      |                  int
      |                 %ld

ソースコード

diff #

#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")

#define MD 998244353ul

unsigned a[][2]={
{        0,        1},
{        1,        1},
{        2,        3},
{       13,       21},
{      610,      987},
{  1346269,  2178309},
{  3164985,868874039},
{268416577, 68921677},
{ 73226039,341969642},
{394135662,104186878},
{492539709,245887711},
{700918724,942839953},
{492450285,188323242},
{310045918, 57949216},
{410017171,490320229},
{869685535,688849975},
{752861792,539562357},
{432433814,123638574},
{  3824821,360202863},
{472156872,494782135},
{ 58989191, 70085358},
{801989325,572234585},
{713664768,618697614},
{173605931,121911603},
{849821511,463493561},
{319107674,994942111},
{ 28542621,845731073},
{295681022,778816073},
{117335797,650103746},
{170833367,658742853},
{759024845,961232082},
{821475450,901056802},
{738819114,806212005},
{557220631,498764237},
{746648672,982428304},
{633343556,474738840},
{235955861, 24695414},
{251954951,797269393},
{579769006,267226822},
{460957071,820525996},
{721762697,381746629},
{512280016, 87518178},
{365690101,209461837},
{588711366,548106755},
{366750805,990012936},
{   121997,953351725},
{420032222,713838745},
{770879409,680616443},
{770256962,160433130},
{311807562,892457479},
{335533397,673858075},
{313827235,262902563},
{303375602,550714785},
{522866582,936139088},
{603459412,255407995},
{382955669,635166915},
{322964226,283451749},
{ 33545516,759538387},
{604456116, 62574976},
{313370250,229945172},
};

typedef unsigned long ulong;

main(){
	ulong n,x0=1,x1=0,y0=0,y1=1;
	scanf("%lu",&n);
	for(n+=2;n;){
		ulong z=__builtin_ctzl(n);
		n-=1ul<<z;
		ulong y0=a[z][0];
		ulong y1=a[z][1];
		ulong t0=x0*y0+x1*y1;
		ulong t1=(x0+x1)*(y0+y1)-x0*y0;
		x0=t0%MD;
		x1=t1%MD;
	}
	printf("%d",(x0+MD-1)%MD);
}
0