ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#183602 | #3293. 赛车高手 | Richard1211 | 100 | 397ms | 1124kb | C++11 | 6.8kb | 2023-08-09 11:55:49 | 2023-08-09 12:38:18 |
answer
//#pragma GCC optimize(3,"Ofast","inline")
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
//#include <bits/extc++.h>
#else
//#include <ext/rope>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/hash_policy.hpp>
//#include <ext/pb_ds/trie_policy.hpp>
//#include <ext/pb_ds/priority_queue.hpp>
#endif
using namespace std;
//using namespace __gnu_cxx;
//using namespace __gnu_pbds;
const double pi=3.141592653589793238462643383279;
template<class T>inline T Min(register T a,register T b){
return a<b?a:b;
}
template<class T>inline T Max(register T a,register T b){
return a>b?a:b;
}
template<class T>inline bool Cmin(register T &a,register T b){
return a>b?(a=b,true):false;
}
template<class T>inline bool Cmax(register T &a,register T b){
return a<b?(a=b,true):false;
}
template<class T>inline T Abs(register T a){
return a>0?a:-a;
}
template<class T>inline T Lowbit(register T x){
return (x)&(-x);
}
template<class T>inline void Swap(register T &a,register T &b){
b^=a^=b^=a;
}
template<class T>inline T Gcd(T a,T b){
return b?Gcd(b,a%b):a;
}
template<class T>inline T Lcm(T a,T b){
return a*b/Gcd(a,b);
}
template<class T>inline T Exgcd(T a,T b,T &x,T &y){
if(b==0){
x=1;
y=0;
return a;
}
T d=Exgcd(b,a%b,x,y);
T t=x;
x=y;
y=t-a/b*y;
return d;
}
template<class T>inline T ExExgcd(T a,T b,T &x,T &y,T c){
if(b==0){
x=c;
y=0;
return a;
}
T d=ExExgcd(b,a%b,x,y,c);
T t=x;
x=y;
y=t-a/b*y;
return d;
}
template<class T>inline T Ksc(T a,T b){
if(a==0||b==0){
return 0;
}
T ans=0;
while(b){
if(b&1){
ans=a+ans;
}
a=a+a;
b>>=1;
}
return ans;
}
template<class T>inline T Ksc(T a,T b,T p){
if(a==0||b==0){
return 0;
}
T ans=0;
while(b){
if(b&1){
ans=(a+ans)%p;
}
a=(a+a)%p;
b>>=1;
}
return ans;
}
template<class T>inline T Ksm(T a,T b,bool f=false){
if(a==0){
return 0;
}
if(b==0){
return 1;
}
T ans=1;
while(b){
if(b&1){
ans=!f?a*ans:Ksc(a,ans);
}
a=!f?a*a:Ksc(a,a);
b>>=1;
}
return ans;
}
template<class T>inline T Ksm(T a,T b,T p,bool f=false){
if(a==0){
return 0;
}
if(b==0){
return 1%p;
}
T ans=1;
while(b){
if(b&1){
ans=!f?a*ans%p:Ksc(a,ans,p);
}
a=!f?a*a%p:Ksc(a,a,p);
b>>=1;
}
return ans;
}
template<class T>inline T Inv(T x,T p){
return Ksm(x,p-2,p);
}
template<class T>inline T Fac(T n){
if(n==0){
return 1;
}
long long ans=1;
for(long long i=1;i<=n;i++){
ans*=i;
}
return ans;
}
template<class T>inline T Fac(T n,T p){
if(n==0){
return 1;
}
long long ans=1;
for(long long i=1;i<=n;i++){
ans=ans*i%p;
}
return ans;
}
template<class T>inline long long Onenum(T x,bool f=true){
return f?__builtin_popcountll(x):__builtin_popcount(x);
}
template<class T>inline long long Lowone(T x,bool f=true){
return f?__builtin_ffsll(x):__builtin_ffs(x);
}
template<class T>inline long long Oneoddeven(T x,bool f=true){
return f?__builtin_parityll(x):__builtin_parity(x);
}
template<class T>inline long long Prezero(T x,bool f=true){
return f?__builtin_clzll(x):__builtin_clz(x);
}
template<class T>inline long long Sufzero(T x,bool f=true){
return f?__builtin_ctzll(x):__builtin_ctz(x);
}
template<class T>inline bool Isdigit(T ch){
return ch>='0' && ch<='9';
}
template<class T>inline bool Isletter(T ch){
return ch>='A' && ch<='Z' || ch>='a' && ch<='z';
}
template<class T>inline void Memset(T *d,long long n,long long s){
for(long long i=0;i<=s-1;i++){
d[i]=n;
}
}
template<class T>inline void debug(T s,string name){
cout << name << ": " << s << endl;
}
template<class T>inline void bug(T s){
cout << s << endl;
}
template<class T>inline T Sin(register T degree){
return sin(degree*(pi/180));
}
template<class T>inline T Cos(register T degree){
return cos(degree*(pi/180));
}
template<class T>inline T Tan(register T degree){
return tan(degree*(pi/180));
}
template<class T>inline T Asin(register T degree){
return asin(degree*(pi/180));
}
template<class T>inline T Acos(register T degree){
return acos(degree*(pi/180));
}
template<class T>inline T Atan(register T degree){
return atan(degree*(pi/180));
}
inline int rd(){
int x=0,f=1;
char ch=getchar();
while(ch<'0' || ch>'9'){
if(ch=='-'){
f=-1;
}
ch=getchar();
}
while(ch>='0' && ch<='9'){
x=(x<<1)+(x<<3)+(ch-'0');
ch=getchar();
}
return x*f;
}
inline long long read(){
long long x=0,f=1;
char ch=getchar();
while(ch<'0' || ch>'9'){
if(ch=='-'){
f=-1;
}
ch=getchar();
}
while(ch>='0' && ch<='9'){
x=(x<<1)+(x<<3)+(ch-'0');
ch=getchar();
}
return x*f;
}
inline unsigned long long Read(){
unsigned long long x=0;
long long f=1;
char ch=getchar();
while(ch<'0' || ch>'9'){
if(ch=='-'){
f=-1;
}
ch=getchar();
}
while(ch>='0' && ch<='9'){
x=(x<<1)+(x<<3)+(ch-'0');
ch=getchar();
}
return x*f;
}
inline bool wrt(int x,char ch='\n'){
static char buf[64];
static int len=-1;
if(x<0){
putchar('-');
x=-x;
}
do{
buf[++len]=x%10;
x/=10;
}
while(x);
while(len>=0){
putchar(buf[len--]+'0');
}
putchar(ch);
return true;
}
inline bool write(long long x,char ch='\n'){
static char buf[64];
static long long len=-1;
if(x<0){
putchar('-');
x=-x;
}
do{
buf[++len]=x%10;
x/=10;
}
while(x);
while(len>=0){
putchar(buf[len--]+'0');
}
putchar(ch);
return true;
}
inline bool Write(unsigned long long x,char ch='\n'){
static char buf[64];
static long long len=-1;
if(x<0){
putchar('-');
x=-x;
}
do{
buf[++len]=x%10;
x/=10;
}
while(x);
while(len>=0){
putchar(buf[len--]+'0');
}
putchar(ch);
return true;
}
inline void OF(string s){
string IN=s+".in";
string OUT=s+".out";
freopen(IN.c_str(),"r",stdin);
freopen(OUT.c_str(),"w",stdout);
}
inline void CF(string s){
fclose(stdin);
fclose(stdout);
}
long long t,x,y;
inline long long f(long long x){
long long sq=sqrtl(x);
return x==0?0:(x==sq*sq?2*sq-1:(x<=sq*(sq+1)?2*sq:2*sq+1));
}
int main(){
t=read();
for(register int i=1;i<=t;++i){
x=read();
y=read();
write(f(Max(x,y)));
}
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Subtask #1:
score: 12
Accepted
Test #1:
score: 12
Accepted
time: 0ms
memory: 1124kb
input:
5 5 2 4 4 3 5 1 7 7 0
output:
4 3 4 5 5
result:
ok 5 number(s): "4 3 4 5 5"
Test #2:
score: 0
Accepted
time: 0ms
memory: 1120kb
input:
5 4 3 5 1 3 5 5 4 0 3
output:
3 4 4 4 3
result:
ok 5 number(s): "3 4 4 4 3"
Test #3:
score: 0
Accepted
time: 0ms
memory: 1124kb
input:
5 2 4 7 7 3 4 1 0 2 5
output:
3 5 3 1 4
result:
ok 5 number(s): "3 5 3 1 4"
Test #4:
score: 0
Accepted
time: 0ms
memory: 1124kb
input:
5 1 5 0 4 3 4 5 5 3 0
output:
4 3 3 4 3
result:
ok 5 number(s): "4 3 3 4 3"
Test #5:
score: 0
Accepted
time: 0ms
memory: 1124kb
input:
5 7 2 2 0 0 0 3 4 1 3
output:
5 2 0 3 3
result:
ok 5 number(s): "5 2 0 3 3"
Test #6:
score: 0
Accepted
time: 0ms
memory: 1124kb
input:
5 6 3 4 6 0 0 0 1 3 6
output:
4 4 0 1 4
result:
ok 5 number(s): "4 4 0 1 4"
Subtask #2:
score: 18
Accepted
Test #7:
score: 18
Accepted
time: 0ms
memory: 1124kb
input:
1000 34 32 44 38 40 40 36 33 35 42 50 39 47 44 35 46 43 42 48 44 36 47 47 34 39 37 41 43 46 45 46 38...
output:
11 13 12 11 12 14 13 13 13 13 13 13 12 13 13 13 11 13 14 13 12 13 11 13 14 13 13 12 11 14 13 13 12 1...
result:
ok 1000 numbers
Test #8:
score: 0
Accepted
time: 0ms
memory: 1120kb
input:
1000 37 30 40 45 30 49 37 46 36 38 42 31 47 35 32 44 43 32 35 30 41 43 48 36 31 50 48 35 35 48 42 31...
output:
12 13 13 13 12 12 13 13 13 11 13 13 14 13 13 12 11 13 12 11 12 13 12 12 12 12 13 13 13 13 13 11 13 1...
result:
ok 1000 numbers
Subtask #3:
score: 23
Accepted
Test #9:
score: 23
Accepted
time: 10ms
memory: 1120kb
input:
100000 841 838 231 460 847 778 618 476 156 915 513 746 799 514 104 726 890 483 768 609 342 200 998 5...
output:
57 42 58 49 60 54 56 53 59 55 36 63 48 60 57 59 49 32 63 35 43 44 47 22 60 57 52 52 44 61 53 60 42 5...
result:
ok 100000 numbers
Test #10:
score: 0
Accepted
time: 7ms
memory: 1124kb
input:
100000 912 98 419 152 759 739 470 38 553 325 253 380 502 424 424 360 427 47 900 214 611 795 147 477 ...
output:
60 40 55 43 47 38 44 41 41 59 56 43 59 47 58 26 29 51 49 53 62 43 58 55 56 38 62 61 59 59 51 61 32 5...
result:
ok 100000 numbers
Test #11:
score: 0
Accepted
time: 8ms
memory: 1120kb
input:
100000 501 999 860 874 392 556 800 209 119 326 819 998 792 634 354 432 891 789 503 341 205 694 347 6...
output:
63 59 47 56 36 63 56 41 59 44 52 51 59 43 62 54 60 56 59 62 55 35 52 57 42 50 40 59 51 62 58 58 48 5...
result:
ok 100000 numbers
Subtask #4:
score: 21
Accepted
Test #12:
score: 21
Accepted
time: 0ms
memory: 1120kb
input:
10000 127242112 331239013 419887545 759000120 404003605 271909138 274815360 989671976 673172191 6209...
output:
36399 55099 40199 62918 51891 48658 56775 59812 58568 58586 60194 39375 56380 28525 55412 52989 5430...
result:
ok 10000 numbers
Test #13:
score: 0
Accepted
time: 2ms
memory: 1124kb
input:
10000 833191680 711905519 995892235 172495560 93436866 66456469 514928589 49749413 368451495 6435858...
output:
57730 63115 19332 45384 38390 34318 38990 60488 58428 39644 40888 56141 58409 46646 51185 47755 5111...
result:
ok 10000 numbers
Test #14:
score: 0
Accepted
time: 0ms
memory: 1120kb
input:
10000 393108867 859390517 304703077 995318776 350647871 438753568 485670762 106497250 783120224 9482...
output:
58630 63097 41892 44075 61587 17380 60705 50037 59567 46798 41746 48250 24109 42278 62359 60096 2981...
result:
ok 10000 numbers
Subtask #5:
score: 26
Accepted
Test #15:
score: 26
Accepted
time: 138ms
memory: 1120kb
input:
300000 700102399929944494 466914043647205576 963273968501598633 43742775117069954 241153529041271553...
output:
1673442439 1962930430 1397577702 1288005461 1826708623 1899820906 1157253013 1647448882 1927604378 1...
result:
ok 300000 numbers
Test #16:
score: 0
Accepted
time: 120ms
memory: 1124kb
input:
300000 914905156460489120 812430935117677043 317659731522230587 84827654902782275 657344151116347785...
output:
1913013493 1127226208 1621535261 1495988556 1256004714 1697822158 1973843358 1933507133 1212197277 1...
result:
ok 300000 numbers
Test #17:
score: 0
Accepted
time: 112ms
memory: 1124kb
input:
300000 591040884900350350 885831892853121821 828686318008633549 889473553177834500 23136283869037978...
output:
1882372856 1886238111 962003822 1710473454 1311321596 1281408943 1401553144 1716761705 1151792299 15...
result:
ok 300000 numbers