結果
| 問題 |
No.81 すべて足すだけの簡単なお仕事です。
|
| コンテスト | |
| ユーザー |
tsuishi
|
| 提出日時 | 2021-02-17 14:11:26 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 4,758 bytes |
| コンパイル時間 | 592 ms |
| コンパイル使用メモリ | 32,000 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-22 16:56:14 |
| 合計ジャッジ時間 | 1,474 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 |
コンパイルメッセージ
main.c: In function 'GETWORD':
main.c:38:63: warning: implicit declaration of function 'getchar_unlocked' [-Wimplicit-function-declaration]
38 | static char *GETWORD(char* str) {char c;char *cp;cp=&str[0];c=getchar_unlocked();while( c != EOF ){if((c==' ')||( c=='\n')) break;*cp++=c;c=getchar_unlocked();}*cp='\0';return &str[0];}
| ^~~~~~~~~~~~~~~~
main.c: In function 'main':
main.c:149:24: warning: implicit declaration of function 'putchar_unlocked' [-Wimplicit-function-declaration]
149 | if( minusFlg ) putchar_unlocked('-');
| ^~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <ctype.h>
#include <quadmath.h>
#include <math.h>
// Yukicoder №81 すべて足すだけの簡単なお仕事です。
// https://yukicoder.me/problems/no/81
// ***********************
// for debug
#define DEBUG
#define NOP do{}while(0)
#ifdef DEBUG
#define TRACE(...) do{printf(__VA_ARGS__);fflush(stdout);}while(0)
#define TRACECR do{putchar_unlocked('\n');fflush(stdout);}while(0)
#else
#define TRACE(...) NOP
#define TRACECR NOP
#endif
#define PRINCR putchar_unlocked('\n')
#define NOCR(strig) do{char *p;p=strchr(strig,'\n');if(p)*p='\0';}while(0)
// The out-of-date function
#define asctime(...) asctime_s(...)
#define ctime(...) ctime_s(...)
#define strlen(a) mystr_len(a)
//#define fopen(...) fopen_s(...)
//#define freopen(...) freopen_s(...)
//#define rewind(a) fseek(a,0L,SEEK_SET)
//#define setbuf(a,b) setvbuf(a,b,_IOFBF,BUFSIZ)
// for stdio
#define GETLINE(str) do{char *p;fgets(str,sizeof(str),stdin);p=strchr(str,'\n');if(p)*p='\0';}while(0)
#define mygc(c) (c)=getchar()
static char *GETWORD( char* str );
static char *GETWORD(char* str) {char c;char *cp;cp=&str[0];c=getchar_unlocked();while( c != EOF ){if((c==' ')||( c=='\n')) break;*cp++=c;c=getchar_unlocked();}*cp='\0';return &str[0];}
#define GETINTS(a,b) {char s[34];int *ap=a;REP(i,b){GETWORD(s);*ap++=atoi(s);}}
static int GETLINEINT(void) {char s[34];GETLINE(s);return atoi(s);}
static int GETWORDINT(void) {char s[34];GETWORD(s);return atoi(s);}
#define SWAP(type,a,b) do{type _c;_c=a;a=b;b=_c;}while(0)
static int max(int a,int b){if(a>b){return a;}return b;}
static int min(int a,int b){if(a<b){return a;}return b;}
// for readaility
typedef long long lolong;
const int INF = 1e9;
const int MOD = 1e9+7;
const lolong LINF = 1e18;
#define PI ((double)3.141592653589793238462643383279)
#define YES(a) printf("%s",((a)?"YES":"NO"))
#define Yes(a) printf("%s",((a)?"Yes":"No"))
#define OK(a) printf("%s",((a)?"OK":"NG"))
#define Ok(a) printf("%s",((a)?"Ok":"Ng"))
#define POSSIBLE(a) printf("%s",((a)?"POSSIBLE":"IMPOSSIBLE"))
#define Possible(a) printf("%s",((a)?"Possible":"Impossible"))
#define SWAP(type,a,b) do{type _c;_c=a;a=b;b=_c;}while(0)
#define REP(a,b) for(int a=0;a<(int)(b);++a)
#define REP1(a,b) for(int a=1;a<=(b);++a)
#define FLOOP(a,b) for(a=0;a<(b);++a)
#define FLOOP1(a,b) for(a=1;a<=(b);++a)
#define ABS(c) ((c)<0?(-(c)):(c))
#define LSB(i) ((i) & -(i))
#define INPBUF (250+2)
#define data_s int
// ***********************
// ***********************
static int cmpint_asc(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
static int cmpint_desc(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
static int cmpchar_asc(const void *a,const void *b){if(*(char *)a>*(char *)b){return 1;}if(*(char *)a==*(char *)b){return 0;}return -1;}
static int cmpchar_desc(const void *a,const void *b){if(*(char *)a<*(char *)b){return 1;}if(*(char *)a==*(char *)b){return 0;}return -1;}
static int mystr_len(char *str){int i=0;do{if(str[i]=='\0')break;i++;if(i>9999)break;}while(1);return i;}
static int countchar(char str[],char c,int limit ) {int cnt = 0;for(int i=0;i<limit;i++) if( str[i] == c )cnt++;return cnt;}
// ***********************
// ***********************
// ***********************
// ***********************
// ***********************
// ***********************
// 外部変数
// ***********************
__float128 GETLINELOLONG( void ) {
// 小数点を嫌い10^10倍する
char str[256];
char *cp,*pp;
int nokori=10;
int decimalsFlg = 0;
int minusFlg = 0;
__float128 val = 0.;
GETLINE(str);
cp = pp = str;
if( *cp == '-' ) {
minusFlg = 1;
cp++;
}
while( *cp != '\0' ) {
if( nokori == 0 ) break;
if(( '0' <= *cp )&&( *cp <= '9' )) {
val *= 10;
val += *cp - '0';
if( decimalsFlg ) nokori--;
} else if( *cp == '.' ) {
decimalsFlg = 1;
}
cp++;
}
while( nokori-- ) val *= 10;
if( minusFlg ) val = - val;
return val;
}
// ***********************
// ***********************
// ***********************
int main() {
int query;
int minusFlg = 0;
__float128 val;
__float128 ans = 0;
long long v,a;
query = GETLINEINT();
REP(i,query) {
val = GETLINELOLONG();
//v = val;
//TRACE("get[%020lld] ", v );
ans = ans + val;
//a = ans;
//TRACE("sum[%020lld]\n", a );
}
v = ans / (__float128)10000000000.;
val = ans - ( v * (__float128)10000000000.);
ans = (__float128)v;
if( val < 0 ) {
minusFlg = 1;
val = - val;
}
if( ans < 0 ) {
minusFlg = 1;
ans = - ans;
}
if( minusFlg ) putchar_unlocked('-');
a = ans;
v = val;
printf("%ld.%010ld\n", a, v );
return 0;
}
tsuishi