結果

問題 No.9008 空白区切りで与えられる数値データの合計値を求める(テスト用)
ユーザー tsuishitsuishi
提出日時 2021-03-31 13:04:48
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 1,177 bytes
コンパイル時間 741 ms
コンパイル使用メモリ 29,764 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-21 07:19:23
合計ジャッジ時間 1,915 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 0 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 0 ms
4,376 KB
testcase_05 AC 1 ms
4,500 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 4 ms
4,376 KB
testcase_11 AC 5 ms
4,380 KB
testcase_12 AC 4 ms
4,376 KB
testcase_13 AC 4 ms
4,376 KB
testcase_14 AC 5 ms
4,380 KB
testcase_15 AC 4 ms
4,380 KB
testcase_16 AC 5 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
extern int getchar_unlocked(void);
extern int putchar_unlocked(int);
#define	ull	unsigned long long
#define	gc(d)	(d)=getchar_unlocked()
#define	pc(d)	putchar_unlocked(d)
static char *GETWORD(char* r) {char c;char *cp;cp=&r[0];gc(c);while(c!=EOF){if((c==' ')||(c=='\n'))break;*cp++=c;gc(c);}*cp='\0';return &r[0];}
void outl(ull n) {
	int i;
	char b[70];
	if (!n) pc('0');
	else {
		if (n < 0) pc('-'), n = -n;
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
	pc('\n');
}
ull a2l(char *r)
{
    ull res;
    ull sign;
    int i;

    res = 0;
    sign = 1;
    i = 0;
    while ((r[i]==' ')||(r[i]=='\t')||(r[i]=='\n')||(r[i]=='\v')||(r[i]=='\r')||(r[i]=='\f')) i++;
	/*
    if (r[i] == '-') sign = -1;
    if (r[i] == '+' || r[i] == '-') i++;
	*/
    while ((r[i]>='0')&&(r[i]<='9')){
		ull	dmy = res;
        res <<= 3;
        dmy <<= 1;
        res = res + dmy;
        res += (ull)(r[i] - '0');
        i++;
    }
    return res * sign;
}
// *********************
int main( void ) {
	int	q;
	ull sum = 0L;
	char s[65];
	GETWORD(s);
	q=(int)a2l(s);
	for(int i=0;i<q;++i){
		GETWORD(s);
		sum+=(ull)a2l(s);
	}
	outl(sum);
}

0