https://horikitacoding.blogspot.com/2019/05/b949-3rd-cpsc-problem-3.html#more
學長也來玩部落格啦XD
我發現這題用scanf,printf比cin/cout的優化快好多
/*1.1s,104KB*/
#include<cstdio>
using namespace std;
int main(){
register long long int a,b;
while(scanf("%lld",&a)!=EOF){
b=a*a;
if(b==1)printf("25\n");
else if(b%4==0)printf("%lld00\n",(b>>2));
else printf("%lld%lld\n",(b>>2),(b%4)*25);
}
return 0;
}
/*1.6s,372KB*/
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
ios::sync_with_stdio(0);
cin.tie(0);
register long long int a,b;
while(cin>>a){
b=a*a;
if(b==1)cout<<"25"<<'\n';
else if(b%4==0)cout<<(b>>2)<<"00"<<'\n';
else cout<<(b>>2)<<(b%4)*25<<'\n';
}
return 0;
}
我發現這題用scanf,printf比cin/cout的優化快好多
/*1.1s,104KB*/
#include
using namespace std;
int main(){
register long long int a,b;
while(scanf("%lld",&a)!=EOF){
b=a*a;
if(b==1)printf("25\n");
else if(b%4==0)printf("%lld00\n",(b>>2));
else printf("%lld%lld\n",(b>>2),(b%4)*25);
}
return 0;
}
/*1.6s,372KB*/
#include
using namespace std;
int main(int argc, char** argv) {
ios::sync_with_stdio(0);
cin.tie(0);
register long long int a,b;
while(cin>>a){
b=a*a;
if(b==1)cout<<"25"<<'\n';
else if(b%4==0)cout<<(b>>2)<<"00"<<'\n';
else cout<<(b>>2)<<(b%4)*25<<'\n';
}
return 0;
}
學長~~~
a為正整數時
b%4只可能是1 or 0 喔
我發現這題用scanf,printf比cin/cout的優化快好多
/*1.1s,104KB*/
#include
using namespace std;
int main(){
register long long int a,b;
while(scanf("%lld",&a)!=EOF){
b=a*a;
if(b==1)printf("25\n");
else if(b%4==0)printf("%lld00\n",(b>>2));
else printf("%lld%lld\n",(b>>2),(b%4)*25);
}
return 0;
}
/*1.6s,372KB*/
#include
using namespace std;
int main(int argc, char** argv) {
ios::sync_with_stdio(0);
cin.tie(0);
register long long int a,b;
while(cin>>a){
b=a*a;
if(b==1)cout<<"25"<<'\n';
else if(b%4==0)cout<<(b>>2)<<"00"<<'\n';
else cout<<(b>>2)<<(b%4)*25<<'\n';
}
return 0;
}
學長~~~
a為正整數時
b%4只可能是1 or 0 喔
好像是這樣,我再想辦法優化(%太耗時間了,改成位元運算好了)
我發現這題用scanf,printf比cin/cout的優化快好多
/*1.1s,104KB*/
#include
using namespace std;
int main(){
register long long int a,b;
while(scanf("%lld",&a)!=EOF){
b=a*a;
if(b==1)printf("25\n");
else if(b%4==0)printf("%lld00\n",(b>>2));
else printf("%lld%lld\n",(b>>2),(b%4)*25);
}
return 0;
}
/*1.6s,372KB*/
#include
using namespace std;
int main(int argc, char** argv) {
ios::sync_with_stdio(0);
cin.tie(0);
register long long int a,b;
while(cin>>a){
b=a*a;
if(b==1)cout<<"25"<<'\n';
else if(b%4==0)cout<<(b>>2)<<"00"<<'\n';
else cout<<(b>>2)<<(b%4)*25<<'\n';
}
return 0;
}
學長~~~
a為正整數時
b%4只可能是1 or 0 喔
好像是這樣,我再想辦法優化(%太耗時間了,改成位元運算好了)
#include<cstdio> using namespace std; int main(){ register long long int a; while(scanf("%lld",&a)!=EOF){ if(a!=1) printf("%lld",(a*a>>2)); if(a&1) printf("25\n"); else printf("00\n"); } }
AC (1s, 96KB)
我發現這題用scanf,printf比cin/cout的優化快好多
/*1.1s,104KB*/
#include
using namespace std;
int main(){
register long long int a,b;
while(scanf("%lld",&a)!=EOF){
b=a*a;
if(b==1)printf("25\n");
else if(b%4==0)printf("%lld00\n",(b>>2));
else printf("%lld%lld\n",(b>>2),(b%4)*25);
}
return 0;
}
/*1.6s,372KB*/
#include
using namespace std;
int main(int argc, char** argv) {
ios::sync_with_stdio(0);
cin.tie(0);
register long long int a,b;
while(cin>>a){
b=a*a;
if(b==1)cout<<"25"<<'\n';
else if(b%4==0)cout<<(b>>2)<<"00"<<'\n';
else cout<<(b>>2)<<(b%4)*25<<'\n';
}
return 0;
}
學長~~~
a為正整數時
b%4只可能是1 or 0 喔
好像是這樣,我再想辦法優化(%太耗時間了,改成位元運算好了)
#include using namespace std; int main(){ register long long int a; while(scanf("%lld",&a)!=EOF){ if(a!=1) printf("%lld",(a*a>>2)); if(a&1) printf("25\n"); else printf("00\n"); } }
AC (1s, 96KB)
#include<cstdio> using namespace std; int main(){ register long long int a; while(scanf("%lld",&a)!=EOF){ if(a!=1) printf("%lld",(a*a>>2)); if(a&1) printf("25\n"); else printf("00\n"); } return 0; }
一個return 0;差這麼多歐!!!
AC (1s, 88KB)
我發現這題用scanf,printf比cin/cout的優化快好多
/*1.1s,104KB*/
#include
using namespace std;
int main(){
register long long int a,b;
while(scanf("%lld",&a)!=EOF){
b=a*a;
if(b==1)printf("25\n");
else if(b%4==0)printf("%lld00\n",(b>>2));
else printf("%lld%lld\n",(b>>2),(b%4)*25);
}
return 0;
}
/*1.6s,372KB*/
#include
using namespace std;
int main(int argc, char** argv) {
ios::sync_with_stdio(0);
cin.tie(0);
register long long int a,b;
while(cin>>a){
b=a*a;
if(b==1)cout<<"25"<<'\n';
else if(b%4==0)cout<<(b>>2)<<"00"<<'\n';
else cout<<(b>>2)<<(b%4)*25<<'\n';
}
return 0;
}
學長~~~
a為正整數時
b%4只可能是1 or 0 喔
好像是這樣,我再想辦法優化(%太耗時間了,改成位元運算好了)
#include using namespace std; int main(){ register long long int a; while(scanf("%lld",&a)!=EOF){ if(a!=1) printf("%lld",(a*a>>2)); if(a&1) printf("25\n"); else printf("00\n"); } }
AC (1s, 96KB)
#include using namespace std; int main(){ register long long int a; while(scanf("%lld",&a)!=EOF){ if(a!=1) printf("%lld",(a*a>>2)); if(a&1) printf("25\n"); else printf("00\n"); } return 0; }
一個return 0;差這麼多歐!!!
AC (1s, 88KB)
人就是要不斷進步:
AC (1s, 72KB)
#include<cstdio> using namespace std; int main(){ unsigned long long int a; while(scanf("%lld",&a)!=EOF){ if(a!=1) printf("%lld",(a*a>>2)); if(a&1) printf("25\n"); else printf("00\n"); } return 0; }