結果
| 問題 | No.3559 +A,-B |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-05-29 20:25:39 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,507 bytes |
| 記録 | |
| コンパイル時間 | 3,572 ms |
| コンパイル使用メモリ | 331,580 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-05-29 20:25:51 |
| 合計ジャッジ時間 | 7,584 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_1 |
(要ログイン)
| サブタスク | 配点 | 結果 |
|---|---|---|
| 部分点1 | 10 % | AC * 2 WA * 2 |
| 部分点2 | 60 % | WA * 7 |
| 部分点3 | 30 % | AC * 2 WA * 9 RE * 9 |
| 合計 | 0 点 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<VL> VVL;
typedef long long LL;
#define all(a) (a).begin(), (a).end()
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
void las(LL p,LL q){
LL x=p+q;
x/=2;
cout<<x<<' '<<p-x<<endl;
}
void f(LL n,LL x,LL y,LL a,LL b,int mod){
//cout<<n<<x<<y<<mod<<endl;
if(mod<=2){
if(x+y>=0){
if(b<=0){
//las(x+y-b*n,x-y+b*n);return;
cout<<x<<' '<<y-b*n<<endl;
}
LL m=(x+y)/b+1;
if(m>=n){cout<<x<<' '<<y-b*n<<endl;return;}
LL p=x+y-b*m,q=x-y+b*m;
f(n-m,(p+q)/2,(p-q)/2,a,b,mod+1);
}
else{
if(a<=0){
cout<<x+a*n<<' '<<y<<endl;return;
}
LL m=-(x+y);
m--; m/=a;
if(m>=n){cout<<x+a*n<<' '<<y<<endl;return;}
LL p=x+y+a*m,q=x-y-a*m;
f(n-m,(p+q)/2,(p-q)/2,a,b,mod+1);
}
}
else{
//cout<<"!"<<n<<x<<y<<a<<b<<endl;
LL m=x+y-n*b;
LL p=-b-m;
p=(p+a+b-1)/(a+b);
LL q=n-p;
//cout<<p<<q<<endl;
//las(x+y+a*p-b*q,x-y-a*p+b*q);
cout<<x+a*p<<' '<<y-b*q<<endl;
}
}
void sol(){
LL n,x,y,a,b;
cin>>n>>x>>y>>a>>b;
f(n,x,y,a,b,0);
}
int main() {std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
int t;cin>>t;
rep(i,t){sol();}
}