Codeforces Round #525 (Div. 2)

匿名 (未验证) 提交于 2019-12-02 23:03:14
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_37868325/article/details/84840942

http://codeforces.com/contest/1088

而且昨晚真的,,cf的提交页面刷不出来,,卡了近5min,导致10min才交了A题,。,然后B题智障,WA了三次。。C题+=写成了=,,,,也是智障错误,,,导致凉凉,,,

-------------------------------------------------------------------------------------------------

A. Ehab and another construction problem

 #include <bits/stdc++.h>  using namespace std; typedef long long ll; int x,ok; int main() {     cin>>x;     for(int i=1;i<=x;i++)      {         for(int j=1;j<=x;j++)         {             if(i%j==0&&i*j>x&&i/j<x)             {                 cout<<i<<" "<<j<<endl;                 return 0;             }         }     }     cout<<"-1"<<endl;     return 0;         /*     if(ok)     cout<<"Yes"<<endl;     else cout<<"No"<<endl;     */ }

B. Ehab and subtraction

我是做复杂了,其实仔细想想,直接去重,然后排个序,挨个输出与前一个的差值就可以了。。我昨晚可能也是有点着急,没有细想就直接暴力模拟了,,,导致WA+2

 #include <bits/stdc++.h>  using namespace std; typedef long long ll; ll x,ok,a[100005],s,n,k; int main() {     map<long long,int>ma;     cin>>n>>k;     s=0;     for(int i=1;i<=n;i++)     {         scanf("%lld",&x);         if(x!=0&&ma[x]==0)         {             a[++s]=x;             ma[x]=1;             //cout<<s<<endl;         }     }     sort(a+1,a+1+s);     int i=1;     x=0;     while(k--)     {         if(i>s) {cout<<"0"<<endl;continue;}         cout<<a[i]-x<<endl;         x+=a[i]-x;         i++;     }     return 0;         /*     if(ok)     cout<<"Yes"<<endl;     else cout<<"No"<<endl;     */ } /*  */

C. Ehab and a 2-operation task

题意给提示了,n+1次,但是我做的时候也是着急了,,因为B题wa了两次,然后就x+=ans,写成了x=ans..

n+1永远成立,逆序,依次,1操作,将第i个数变成(n+1)的某倍数+i,第i+1步全部取余(n+1)就可以了。。

 #include <bits/stdc++.h>  using namespace std; typedef long long ll; ll x,ok,a[10005],s,n,ans; int main() {     cin>>n;     for(int i=1;i<=n;i++)     {         scanf("%lld",&a[i]);     }     x=0;     cout<<n+1<<endl;     for(int i=n;i>=1;i--)     {         s=a[i];         s+=x;         if((s%(n+1))-i<=0)         {             ans=i-(s%(n+1));             x+=ans;         }         else         {             ans=n-(s%(n+1))+i+1;             x+=ans;         }         cout<<"1 "<<i<<" "<<ans<<endl;     }     cout<<"2 "<<n<<" "<<n+1<<endl;     return 0;         /*     if(ok)     cout<<"Yes"<<endl;     else cout<<"No"<<endl;     */ } /*  */

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!