首页 > 其他分享 >Codeforces Round #667 (Div. 3) ABCD

Codeforces Round #667 (Div. 3) ABCD

时间:2022-11-01 21:57:43浏览次数:60  
标签:ABCD 10 const cout idx 667 LL cin Div

https://codeforces.com/contest/1409

A. Yet Another Two Integers Problem

题目大意:

k∈[1;10] 我们每次可以选择 a:=a+k or a:=a−k

问a要经历多少次操作变成b?
input 
6
5 5
13 42
18 4
1337 420
123456789 1000000000
100500 9000
output 
0
3
2
92
87654322
9150
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18;
const LL N=10000200,M=2002;
const LL mod=1e9+7;
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    LL T=1;
    cin>>T;
    while(T--)
    {
        LL a,b;
        cin>>a>>b;
        LL sum=abs(a-b);
        LL res=sum/10;
        if(sum%10!=0) res++;
        cout<<res<<endl;
    }
    return 0;
}

B. Minimum Product

题目大意:

给定a,b,x,y和n,我们每次可以把a减掉一次,或者b减掉一次,最多总操作数是n次;

但是必须保证a>=x,b>=y;

问我们a*b的最大值是多少?
input
7
10 10 8 5 3
12 8 8 7 2
12343 43 4543 39 123212
1000000000 1000000000 1 1 1
1000000000 1000000000 1 1 1000000000
10 11 2 1 5
10 11 9 1 10
output 
70
77
177177
999999999000000000
999999999
55
10

找规律即可

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18;
const LL N=10000200,M=2002;
const LL mod=1e9+7;
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    LL T=1;
    cin>>T;
    while(T--)
    {
        LL a,b,x,y,n;
        cin>>a>>b>>x>>y>>n;
        LL minn=MAXN;
        LL a1=0,b1=0;
        a1=max(x,a-n);
        b1=max(y,b-(n-(a-a1)));
        minn=min(minn,a1*b1);
        //cout<<a1<<" "<<b1<<endl;

        b1=max(y,b-n);
        a1=max(x,a-(n-(b-b1)));
        minn=min(minn,a1*b1);
        //cout<<a1<<" "<<b1<<endl;

        cout<<minn<<endl;
    }
    return 0;
}

C. Yet Another Array Restoration

题目大意:

给定数组总个数,以及数组中必定包含的两个数字

让我们构建出方差一致的数组a(保证数组a一定存在)。
input 
5
2 1 49
5 20 50
6 20 50
5 3 8
9 13 22
output 
1 49 
20 40 30 50 10
26 32 20 38 44 50 
8 23 18 13 3 
1 10 13 4 19 22 25 16 7 
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18;
const LL N=10000200,M=2002;
const LL mod=1e9+7;
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    LL T=1;
    cin>>T;
    while(T--)
    {
        LL n,x,y;
        cin>>n>>x>>y;
        if(n==2)
        {
            cout<<x<<" "<<y<<endl;
        }
        else
        {
            LL rest=y-x;
            LL num=n-1;
            while(rest%num!=0)
            {
                num--;
            }
            LL ad=rest/num;
            //cout<<num<<" "<<ad<<endl;
            LL sum=num+1;
            vector<LL> v;
            //cout<<"sum "<<sum<<endl;
            if(n>sum)
            {
                LL idx=1;
                while(x-idx*ad>=1&&n>sum)
                {
                    v.push_back(x-idx*ad);
                    sum++;
                    idx++;
                }
                idx=1;
                while(sum<n)
                {
                    v.push_back(y+idx*ad);
                    sum++;
                    idx++;
                }
            }
            for(LL i=x;i<=y;i+=ad)
            {
                v.push_back(i);
            }
            for(LL i=0;i<v.size();i++)
            {
                cout<<v[i]<<" ";
            }
            cout<<endl;
        }
    }
    return 0;
}

D. Decrease the Sum of Digits

题目大意:

问我们这个数字n能够满足数位<=m的最小变化次数是多少?

每次变化就是+1。
input 
5
2 1
1 1
500 4
217871987498122 10
100000000000000001 1
output 
8
0
500
2128012501878
899999999999999999

abc有一个和这个好像的!!!

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
const LL MAXN=1e18;
const LL N=5000200,M=2002;
const LL mod=1e9+7;
LL idx[N],sum[N];
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    LL T=1;
    cin>>T;
    while(T--)
    {
        LL n,m;
        cin>>n>>m;
        for(int i=0;i<=18;i++)
        {
            if(i==0) idx[i]=1;
            else idx[i]=idx[i-1]*10;
        }
        string s=to_string(n);
        s=" "+s;
        for(int i=1;i<s.size();i++)
        {
            sum[i]=sum[i-1]+(s[i]-'0');
        }
        LL odd=n;
        LL now=n;
        for(int i=s.size()-1,k=1;i>=1;i--,k++)
        {
            if(sum[i]>m)
            {
                now/=idx[k];
                now*=idx[k];
                now+=idx[k];
            }
            //cout<<now<<endl;
            s=to_string(now);
            s=" "+s;
            for(int j=1;j<s.size();j++)
                sum[j]=sum[j-1]+(s[j]-'0');
        }
        //cout<<now<<endl;
        cout<<now-odd<<endl;
    }
    return 0;
}

标签:ABCD,10,const,cout,idx,667,LL,cin,Div
From: https://www.cnblogs.com/Vivian-0918/p/16849290.html

相关文章

  • Educational Codeforces Round 81 (Rated for Div. 2) D
    D.SameGCDs对于题目所给的公式gcd(a,m)=gcd(a+x,m)由辗转相除我们把第二个式子变一下gcd((a+x)%m,m)x的取值范围为[0,m)(a+x)%m也是所以我们可以直接写成gcd(a,m)=g......
  • Codeforces Round #113 (Div. 2) E. Tetrahedron(dp/递推)
    https://codeforces.com/problemset/problem/166/E题目大意:给定一个正三角锥,最上面的顶点是D点,下面三个点分别标号为ABC给定n次,我们初始化在D点上,并且要求最后第n步也......
  • Codeforces Round #650 (Div. 3) D
    D.TaskOnTheBoard观察样例我们发现一定会有0的存在然后呢?我们发现给出的题意中只是小的字符一定会加上与比它大的字符的距离数据范围是50我们知道了最大的字符......
  • Codeforces Round #667 (Div. 3) E
    E.TwoPlatforms读完题发现好像跟y坐标没关系考虑dpdp[i][0/1/2]表示以第i个点结尾的用了0/1/2个板子的max显然我们对于0我们都是初始化为0对于dp[i][1]我们直接dp[......
  • Divide Points
    传送门Sol1神奇的构造。。思路自然直接:枚举\(Dist\),对所有\(dist(i,j)=Dist\)的点对连接\(i,j\),然后剔除所有度数为\(0\)的点,这样就建立了一张图。然后跑dfs判......
  • Codeforces Round #617 (Div. 3) E1
    E1.StringColoring(easyversion)观察样例我们发现要是最长下降子序列要是>=3那我们显然不可能有解然后我们考虑构造要是最长最长下降子序列只是2的话那显然我们只......
  • HTML如何让IMG自动适应DIV容器大小
    HTML如何让IMG自动适应DIV容器大小为了让IMG自适应大小,如下我做了一个横向自适应的示例:IMG样式(横向拉伸,纵向自动匹配大小)DIV样式(元素居中显示)IMG样式(横向拉伸,纵向自动匹配大......
  • html-span与div
    Div自己独占一行一行上可以有多个span实现网络布局<div>我是一个div标签我一个人占一整行</div>  <span>新浪</span>  <span>百度</span>Div相当于一个独占......
  • ABC 275 ABCD ( dfs / 递推递归+记忆化搜索)
    https://atcoder.jp/contests/abc275/tasksA-FindTakahashi题目大意:求数组最大值的数字下标。SampleInput13508070SampleOutput12#include<bits/st......
  • 固定高度的div在屏幕中居中方法
    如何将一个固定高度的div居中在屏幕中间呢?先来看个例子,定义一个div并设置其高度为600px;html代码:<divclass='a'></div>css样式代码:.a{height:600px;background......