結果
| 問題 |
No.9008 空白区切りで与えられる数値データの合計値を求める(テスト用)
|
| ユーザー |
tsuishi
|
| 提出日時 | 2021-03-31 13:04:48 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 2,000 ms |
| コード長 | 1,177 bytes |
| コンパイル時間 | 136 ms |
| コンパイル使用メモリ | 30,848 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-14 16:35:24 |
| 合計ジャッジ時間 | 1,028 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 15 |
ソースコード
#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);
}
tsuishi