結果
問題 | No.347 微分と積分 |
ユーザー |
![]() |
提出日時 | 2016-02-29 20:26:38 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 381 bytes |
コンパイル時間 | 188 ms |
コンパイル使用メモリ | 30,976 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-24 12:54:17 |
合計ジャッジ時間 | 980 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:13:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | scanf( "%d%lf", &N, &B ); | ~~~~~^~~~~~~~~~~~~~~~~~~ main.cpp:18:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 18 | scanf( "%lf", a+i ); | ~~~~~^~~~~~~~~~~~~~
ソースコード
#include<cstdio> #include<cmath> #define rep(i,a) for(int i=0;i<(a);++i) const int MAX_N = 10; int N; double B; double a[MAX_N]; int main() { scanf( "%d%lf", &N, &B ); double dr = 0, it = 0; rep( i, N ) { scanf( "%lf", a+i ); dr += a[i]*pow(B,a[i]-1); it += a[i]!=-1?pow(B,a[i]+1)/(a[i]+1):log(B); } printf( "%.4f\n", dr ); printf( "%.4f\n", it ); return 0; }