250->500
T1
大水题
#include<bits/stdc++.h>
using namespace std;
int main(){
freopen("bread.in","r",stdin);
freopen("bread.out","w",stdout);
int n,k;
cin>>n>>k;
cout<<(n==0?0:(k>=n?2:ceil(2*n*1.0/k)));
return 0;
}
T2
为此我还去看了看链式前向星
#include<bits/stdc++.h>
using namespace std;
const int N=10007;
struct edge{
int next,to;
}a[400005];
int edgenum,head[200005],w[200005],n,ans,maxx;
void add(int u,int v){
a[++edgenum].next=head[u];
a[edgenum].to=v;
head[u]=edgenum;
}
int main(){
freopen("expand.in","r",stdin);
freopen("expand.out","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin>>n;
for(int i=1;i<n;i++){
int u,v;
cin>>u>>v;
add(u,v);
add(v,u);
}
for(int i=1;i<=n;i++){
cin>>w[i];
}
for(int i=1;i<=n;i++){
int max1=0,max2=0;
int t1=0,t2=0;
for(int j=head[i];j;j=a[j].next){
if(w[a[j].to]>max1){
max2=max1,max1=w[a[j].to];
}
else{
if(w[a[j].to]>max2){
max2=w[a[j].to];
}
}
t1=(t1+w[a[j].to])%N;
t2=(t2+w[a[j].to]*w[a[j].to])%N;
}
t1=t1*t1%N;
ans=(ans+t1+N-t2)%N;
maxx=max(maxx,max1*max2);
}
cout<<maxx<<" "<<ans;
return 0;
}
T3
大水题,考试nc爆零
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[100002],maxx=-1;
int main(){
freopen("mountain.in","r",stdin);
freopen("mountain.out","w",stdout);
ll n,ans=0;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
if(a[i]>maxx){
maxx=max(maxx,a[i]);
ans++;
}
}
cout<<ans;
return 0;
}
T4
模拟
#include<bits/stdc++.h>
using namespace std;
char a[15];
bool b[5];
int c[10];
int main(){
freopen("prize.in","r",stdin);
freopen("prize.out","w",stdout);
ios::sync_with_stdio(false);
cout.tie(0);
int pd11=0,pd12=0,pd13=0,pd2=0,pd31=0,pd32=0,ans=0,pd=0;
for(int i=1;i<=5;i++){
scanf("%c ",&a[i]);
(a[i]=='A'||a[i]=='B')?pd11++:pd11;
a[i]=='A'?pd31++:pd31;
}
for(int i=6;i<=10;i++){
scanf("%d ",&c[i]);
c[i]==0?b[2]=true:b[2];
(c[i]==0||c[i]==1)?pd12++:pd12;
}
scanf("%c ",&a[11]);
a[11]=='Y'?(pd13++,pd32++):(pd13,pd32);
(pd11==5&&pd12!=0&&pd13!=0)?b[1]=true:b[1];
(pd31==5&&pd32!=0)?b[3]=true:b[3];
scanf("%c",&a[12]);
if(a[12]=='Y'){
b[1]==true?ans+=3000:ans;
b[2]==true?ans+=2000:ans;
b[3]==true?ans+=1000:ans;
}
else{
b[1]==true?(ans=3000,pd=1):(ans,pd);
(b[2]==true&&pd!=1)?(ans=2000,pd=1):(ans,pd);
(b[3]==true&&pd!=1)?(ans=1000,pd=1):(ans,pd);
}
cout<<ans;
return 0;
}
T5
毕达哥拉斯三元组
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll ans,n,m;
int main(){
freopen("gou.in","r",stdin);
freopen("gou.out","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin>>n;
for(int i=1;i*i<=n;i++){
for(int j=i+1;j*j<=n;j++){
if(__gcd(i,j)==1&&(i+j)%2==1){
ans+=(n/(i*i+j*j));
}
}
}
cout<<ans;
return 0;
}
总结
开合跳比俯卧撑简单多了!