2017-9-9 NOIP模擬賽
阿新 • • 發佈:2017-09-09
ostream class close sed -- while cst break event
站軍姿
2bc*cosA=b^2+c^2-a^2
對剛
3
#include<iostream> #include<cstdio> #include<cstring> #define maxn 100010 using namespace std; int n,t,sum; bool vis[maxn]; struct node{ int nxt,pre; }q[maxn]; int main(){ //freopen("Cola.txt","r",stdin); freopen("100分 鏈表模擬resist.in","r",stdin); freopen("resist.out","w",stdout); scanf("%d%d",&n,&t); sum=n-1; for(int i=1;i<=n;i++){ q[i].pre=i-1;q[i].nxt=i+1; } q[1].pre=n;q[n].nxt=1; int pos=1,cnt=0; while(sum){ cnt++; if(cnt==t){ q[q[pos].pre].nxt=q[pos].nxt; q[q[pos].nxt].pre=q[pos].pre; vis[pos]=1; sum--; cnt=0; } pos=q[pos].nxt; } for(int i=1;i<=n;i++){ if(!vis[i]){ printf("%d",i); return 0; } } }
隔壁
#include<iostream> #include<cstdio> #include<cstring> using namespace std; #define maxn 1010 int n,m,a[maxn],b[maxn],c[maxn]; long long map[maxn][maxn]; long long ans1,ans2; bool v1[maxn]; int main(){ //freopen("Cola.txt","r",stdin); freopen("neighbor.in","r",stdin); freopen("neighbor.out","w",stdout); scanf("%d%d",&n,&m); for(int i=1;i<=n;i++)scanf("%d",&c[i]); for(int i=1;i<=m;i++)scanf("%d",&b[i]); for(int i=1,j=n;i<=n;i++,j--)a[i]=c[j]; int mark; for(int i=1;i<=n;i++){ bool flag=0; for(int j=1;j<=m;j++){ if(b[j]==a[i]&&!v1[j]){ v1[j]=1; ans1+=a[i]; flag=1; break; } if(b[j]>a[i])mark=j; } if(!flag){ ans1+=a[i]; } } for(int i=1;i<=m;i++){ if(!v1[i]){ ans1+=b[i]; } } cout<<ans1<<‘ ‘; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ if(b[j]>=a[i]) map[i][j]=a[i]; } } for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ if(b[j]<=a[i]) map[i][j]=b[j]; ans2+=map[i][j]; } } cout<<ans2; return 0; }100分 貪心
2017-9-9 NOIP模擬賽