結果
| 問題 |
No.2966 Simple Plus Minus Problem
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-02-28 16:18:44 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 840 bytes |
| コンパイル時間 | 1,851 ms |
| コンパイル使用メモリ | 192,800 KB |
| 実行使用メモリ | 7,040 KB |
| 最終ジャッジ日時 | 2025-02-28 16:18:54 |
| 合計ジャッジ時間 | 9,952 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 4 WA * 50 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:24:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
24 | scanf("%d%d",&n,&k);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:25:32: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
25 | for(i=1;i<=n;i++) scanf("%lld",&a[i]);
| ~~~~~^~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3fLL;
const int MAX=2e5+10;
const int mod=998244353;
ll qpow(ll a,ll b)
{
ll res=1;
while(b>0)
{
if(b&1) res=res*a%mod;
a=a*a%mod;
b>>=1;
}
return res;
}
ll inv(ll x){return qpow(x,mod-2);}
ll a[MAX],res[MAX];
int main()
{
int n,k,i;
scanf("%d%d",&n,&k);
for(i=1;i<=n;i++) scanf("%lld",&a[i]);
for(i=1;i<=n;i++)
{
if(i>=3 && (i&1)) res[i]=(a[i-2]*(k/2)+a[i])%mod;
else res[i]=a[i];
}
k%=2;
if(k)
{
for(i=1;i<=n;i++)
{
if(i%2==0) res[i]=(res[i-1]-res[i]+mod)%mod;
else res[i]=(res[i-1]+res[i])%mod;
}
}
for(i=1;i<=n;i++) printf("%lld%c",res[i]," \n"[i==n]);
return 0;
}
/*
a1 a1-a2 a1-a2+a3 a1-a2+a3-a4
a1 a2 a1+a3 a2+a4
a1 a1-a2 2a1-a2+a3 2a1-2a2+a3-a4
a1 a2 2a1+a3 2a2+a4
*/
vjudge1