Submission #26159554
Source Code Expand
#include<iostream>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int MAXN =200005;
ll n, t[200005],s,p;
ll a[200005];
ll cal(ll x){
ll z=1;
ll ans=0;
if(x==0)return 0;
while(x%z==0){
ans++;
z*=p;
}
return ans-1;
}
bool cust(pair<ll,ll>&x,pair<ll,ll>&y){
if(x.first!=y.first)return x.first<y.first;
else return x.second>y.second;
}
ll power(long long x, ll y, ll p)
{
ll res = 1;
x = x % p;
if (x == 0) return 0;
while (y > 0)
{
if (y & 1)
res = (res*x) % p;
y = y>>1;
x = (x*x) % p;
}
return res;
}
void build(ll a[], int v, int tl, int tr) {
if (tl == tr) {
t[v] = cal(pow(a[tl],s)-pow(a[tl]%p,s));
} else {
int tm = (tl + tr) / 2;
build(a, v*2, tl, tm);
build(a, v*2+1, tm+1, tr);
t[v] = t[v*2] + t[v*2+1];
}
}
ll sum(int v, int tl, int tr, int l, int r) {
if (l > r)
return 0;
if (l == tl && r == tr) {
return t[v];
}
int tm = (tl + tr) / 2;
return sum(v*2, tl, tm, l, min(r, tm))
+ sum(v*2+1, tm+1, tr, max(l, tm+1), r);
}
void update(int v, int tl, int tr, int pos, ll new_val) {
if (tl == tr) {
t[v] = cal(pow(new_val,s)-pow(new_val%p,s));
} else {
int tm = (tl + tr) / 2;
if (pos <= tm)
update(v*2, tl, tm, pos, new_val);
else
update(v*2+1, tm+1, tr, pos, new_val);
t[v] = t[v*2] + t[v*2+1];
}
}
void calpar(vector<vector<ll>>&adj,ll s,ll p,ll prev,vector<ll>&par){
par[s]=prev;
for(auto j:adj[s]){
if(j!=p){
calpar(adj,j,s,prev+1,par);
}
}
}
ll calch(vector<vector<ll>>&adj,ll s,ll p,vector<ll>&ch){
for(auto j:adj[s]){
if(j!=p){
ch[s]+=(ll)(1ll+calch(adj,j,s,ch));
}
}
return ch[s];
}
ll caldis(vector<vector<ll>>&adj,ll s,ll p,ll prevdis,vector<ll>&dis){
for(auto j:adj[s]){
if(j!=p){
dis[s]+=(ll)(prevdis+1);
dis[s]+=caldis(adj,j,s,prevdis+1,dis);
}
}
return dis[s];
}
void fin(vector<vector<ll>>&adj,ll s,ll p,vector<ll>&dis,vector<ll>&par,vector<ll>&ch,ll &n){
//cout<<s<<" "<<dis[p]<<" "<<ch[p]<<" "<<par[p]<<" "<<ch[s]<<endl;
dis[s]=dis[p];
dis[s]+=n;
dis[s]-=ch[s];
dis[s]-=ch[s];
dis[s]-=2;
for(auto j:adj[s]){
if(j!=p){
fin(adj,j,s,dis,par,ch,n);
}
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t=1,l;
//cin>>t;
//for(int i=0;i<100;i++)cout<<x[i]<<" ";
//cout<<x.size()<<endl;
//for(auto j:ans)cout<<(j)<<" ";cout<<endl;
ll mod=998244353;
for(int q=1;q<=t;q++) {
ll k;
cin>>k;
string a,b;
cin>>a>>b;
ll z=1;
ll x=0;
for(int i=a.size()-1;i>=0;i--){
x+=z*(a[i]-'0');
z*=k;
}
ll y=0;
z=1;
for(int i=b.size()-1;i>=0;i--){
y+=z*(b[i]-'0');
z*=k;
}
//cout<<x<<" "<<y<<endl;
cout<<x*y<<endl;
//cout<<"Case #"<<q<<": ";
//for(int i=0;i<m;i++)cout<<ans[i]<<" ";cout<<endl;
}
}
Submission Info
| Submission Time |
|
| Task |
B - Base K |
| User |
prateek3110 |
| Language |
C++ (GCC 9.2.1) |
| Score |
200 |
| Code Size |
3506 Byte |
| Status |
AC |
| Exec Time |
8 ms |
| Memory |
3624 KiB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:117:13: warning: unused variable ‘l’ [-Wunused-variable]
117 | int t=1,l;
| ^
./Main.cpp:122:8: warning: unused variable ‘mod’ [-Wunused-variable]
122 | ll mod=998244353;
| ^~~
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
200 / 200 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
example0.txt, example1.txt |
| All |
000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, example0.txt, example1.txt |
| Case Name |
Status |
Exec Time |
Memory |
| 000.txt |
AC |
8 ms |
3460 KiB |
| 001.txt |
AC |
2 ms |
3520 KiB |
| 002.txt |
AC |
2 ms |
3464 KiB |
| 003.txt |
AC |
2 ms |
3576 KiB |
| 004.txt |
AC |
2 ms |
3524 KiB |
| 005.txt |
AC |
4 ms |
3520 KiB |
| 006.txt |
AC |
1 ms |
3460 KiB |
| 007.txt |
AC |
2 ms |
3460 KiB |
| example0.txt |
AC |
2 ms |
3452 KiB |
| example1.txt |
AC |
2 ms |
3624 KiB |