結果

問題 No.836 じょうよ
ユーザー tailstails
提出日時 2020-10-22 19:34:12
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 665 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 30,080 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-21 09:26:28
合計ジャッジ時間 1,506 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 0 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 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 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 0 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
testcase_31 AC 1 ms
5,376 KB
testcase_32 AC 0 ms
5,376 KB
testcase_33 AC 1 ms
5,376 KB
testcase_34 AC 1 ms
5,376 KB
testcase_35 AC 1 ms
5,376 KB
testcase_36 AC 1 ms
5,376 KB
testcase_37 AC 1 ms
5,376 KB
testcase_38 AC 1 ms
5,376 KB
testcase_39 AC 1 ms
5,376 KB
testcase_40 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'cp':
main.c:8:17: warning: implicit declaration of function 'memcpy' [-Wimplicit-function-declaration]
    8 |                 memcpy(w,s,slen);
      |                 ^~~~~~
main.c:1:1: note: include '<string.h>' or provide a declaration of 'memcpy'
  +++ |+#include <string.h>
    1 | #pragma GCC optimize("Ofast")
main.c:8:17: warning: incompatible implicit declaration of built-in function 'memcpy' [-Wbuiltin-declaration-mismatch]
    8 |                 memcpy(w,s,slen);
      |                 ^~~~~~
main.c:8:17: note: include '<string.h>' or provide a declaration of 'memcpy'
main.c: At top level:
main.c:24:1: warning: return type defaults to 'int' [-Wimplicit-int]
   24 | main(){
      | ^~~~
main.c: In function 'main':
main.c:27:9: warning: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
   27 |         scanf("%ld%ld%d",&l,&r,&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:27:9: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
   27 |         scanf("%ld%ld%d",&l,&r,&n);
      |         ^~~~~
main.c:27:9: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:32:19: warning: implicit declaration of function 'sprintf' [-Wimplicit-function-declaration]
   32 |         int s0len=sprintf(s0,"%ld\n",d);
      |                   ^~~~~~~
main.c:32:19: note: include '<stdio.h>' or provide a declaration of 'sprintf'
main.c:32:19: warning: incompatible implicit declaration of built-in function 'sprintf' [-Wbuiltin-declaration-mismatch]
main.c:32:19: note: include '<stdio.h>' or provide a declaration of 'sprintf'
main.c:48:9: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration]
   48 |         write(1,buf,w-buf);
      |         ^~~~~
main.c:49:9: warning: implicit declaration of function '_exit'; did 

ソースコード

diff #

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

char buf[3200000],*w=buf;

void cp(char*s,int slen,int num){
	if(num){
		memcpy(w,s,slen);
		s=w;
		w+=slen;
		--num;
		int m=1;
		while(num){
			if(m>num) m=num;
			int t=slen*m;
			memcpy(w,s,t);
			w+=t;
			num-=m;
			m<<=1;
		}
	}
}

main(){
	long l,r;
	int n;
	scanf("%ld%ld%d",&l,&r,&n);
	++r;

	long d=(r-l)/n;
	char s0[32],s1[32];
	int s0len=sprintf(s0,"%ld\n",d);
	int s1len=sprintf(s1,"%ld\n",d+1);

	l%=n;
	r%=n;
	int i=0;
	if(l<=r){
		cp(s0,s0len,l);
		cp(s1,s1len,r-l);
		cp(s0,s0len,n-r);
	}else{
		cp(s1,s1len,r);
		cp(s0,s0len,l-r);
		cp(s1,s1len,n-l);
	}

	write(1,buf,w-buf);
	_exit(0);
}

0