結果
| 問題 |
No.1915 Addition
|
| コンテスト | |
| ユーザー |
じゅんにー
|
| 提出日時 | 2022-04-29 21:30:04 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 3,023 bytes |
| コンパイル時間 | 1,689 ms |
| コンパイル使用メモリ | 184,828 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-29 02:48:32 |
| 合計ジャッジ時間 | 2,630 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 10 |
ソースコード
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(int)(n);i++)
using namespace std;
using ll=long long;
using ld=long double;
using pai=pair<int,int>;
using pall=pair<ll,ll>;
using vint=vector<int>;
using vll=vector<ll>;
using pquel=priority_queue<ll,vector<ll>,greater<ll>>;
using pquei=priority_queue<int,vector<int>,greater<int>>;
ll one=1,zero=0;
const string yes="Yes",no="No";
const ll bip=1000000007,sap=998244353;
const ld pi=3.1415926535897932384626433832;
const int inty=(one<<31)-1;
const ll lly=(one<<63)-1;
unordered_map<ll,ll>uf;
unordered_map<ll,ll>ufo;
void ufi(ll &x){
if(ufo[x]==0){
ufo[x]=1;
uf[x]=x;
}
return;
}
void ufm(ll &x,ll &y){
ufi(x);
ufi(y);
queue<ll>q;
q.push(x);
q.push(y);
while(uf[x]!=x){
x=uf[x];
q.push(x);
}
while(uf[y]!=y){
y=uf[y];
q.push(y);
}
while(!(q.empty())){
y=q.front();
q.pop();
uf[y]=x;
}
return;
}
void uft(ll &x){
ufi(x);
ll y;
queue<ll>q;
q.push(x);
while(uf[x]!=x){
x=uf[x];
q.push(x);
}
while(!(q.empty())){
y=q.front();
q.pop();
uf[y]=x;
}
return;
}
ll divi(ll a,ll b){
b=abs(b);
a=(a%b+b)%b;
if(2*a<b)return a;
return a-b;
}
ll modinv(ll a,ll b){
if(abs(a)==1)return a;
return (-b*modinv(divi(b,a),a)+1)/a;
}
ll modpow(ll a,ll b,ll c){
ll s=1,t=1;
a%=c;
for(int i=0;i<64;i++){
if(b&t){
s=(s*a)%c;
}
a=(a*a)%c;
t*=2;
}
return s;
}
bool issq(ll n){
if(n<0)return false;
ll i=sqrt(n);
while(i*i<=n){
if(n==i*i)return true;
i++;
}
return false;
}
vector<pair<double,double>>fft(int &n,vector<pair<double,double>>&pol){
if(n==1)return pol;
n/=2;
vector<pair<double,double>>f1(n),f2(n),f3(n*2);
for(int i=0;i<n;i++){
f1[i]=pol[2*i];
f2[i]=pol[2*i+1];
}
f1=fft(n,f1);
f2=fft(n,f2);
for(int i=0;i<n;i++){
f3[i].first=f1[i].first+cos(i*pi/n)*f2[i].first-sin(i*pi/n)*f2[i].second;
f3[i].second=f1[i].second+sin(i*pi/n)*f2[i].first+cos(i*pi/n)*f2[i].second;
}
for(int i=0;i<n;i++){
f3[i+n].first=f1[i].first-cos(i*pi/n)*f2[i].first+sin(i*pi/n)*f2[i].second;
f3[i+n].second=f1[i].second-sin(i*pi/n)*f2[i].first-cos(i*pi/n)*f2[i].second;
}
n*=2;
return f3;
}
vector<pair<double,double>>invfft(int &n,vector<pair<double,double>>&pol){
if(n==1)return pol;
n/=2;
vector<pair<double,double>>f1(n),f2(n),f3(n*2);
for(int i=0;i<n;i++){
f1[i]=pol[2*i];
f2[i]=pol[2*i+1];
}
f1=invfft(n,f1);
f2=invfft(n,f2);
for(int i=0;i<n;i++){
f3[i].first=f1[i].first+cos(i*pi/n)*f2[i].first+sin(i*pi/n)*f2[i].second;
f3[i].second=f1[i].second-sin(i*pi/n)*f2[i].first+cos(i*pi/n)*f2[i].second;
}
for(int i=0;i<n;i++){
f3[i+n].first=f1[i].first-cos(i*pi/n)*f2[i].first-sin(i*pi/n)*f2[i].second;
f3[i+n].second=f1[i].second+sin(i*pi/n)*f2[i].first-cos(i*pi/n)*f2[i].second;
}
n*=2;
return f3;
}
int main(){
int t;
cin>>t;
ll n,k;
while(t--){
cin>>n;
k=10;
while(k<=n){
k*=10;
}
cout<<10*k-1-n<<endl;
}
}
じゅんにー