首页 > 其他分享 >Educational Codeforces Round 1

Educational Codeforces Round 1

时间:2023-01-11 16:24:31浏览次数:57  
标签:Educational temp int cin Codeforces while Round

Problem - A - Codeforces

void solve()
{
    ios;
    int t;
    cin >> t;
    while(t -- )
    {
        int n;
        cin >> n;
        int sum = n * (n + 1) / 2;
        int temp = 1;
        while(1)
        {
            sum -= temp * 2;
            temp *= 2;
            if(temp > n)
            {
                break;
            }
        }
        cout << sum << "\n";
        
    }
}
View Code

 

标签:Educational,temp,int,cin,Codeforces,while,Round
From: https://www.cnblogs.com/codeforceshobby/p/17044124.html

相关文章

  • 一个CF1775C(Codeforces Round #843 (Div. 2))的小技巧
    若\(n\)的第\(i\)位为\(1\),而我们需要不断令\(n+1\)找到下一个最小的\(k\),使得\(k\)的第\(i\)位为\(0\)。技巧:假设\(n\)为10101[1]1001,括号内是要求的第\(i\)位那么先......
  • CF Codeforces Round #843 (Div. 2)
    CodeforcesRound#843(Div.2)本次脑袋不大灵光,一方面可能是怕掉分。另一方面就是交的人实在是太少了,导致我一直不敢交,其实这场cf没有我想象中那么难,甚至来说我一直是......
  • Educational Codeforces Round 141
    目录写在前面ABCDEF写在最后写在前面比赛地址:https://codeforces.com/contest/1783。CF车队翻车咯,本来上大分,喜提skippedA如果所有数均相等则无解。否则先降序排序......
  • Codeforces Round #843 (Div. 2) 做题记录
    CodeforcesRound#843(Div.2)做题记录A1&A2.GardenerandtheCapybarasProblemCF1775A2GardenerandtheCapybaras题目大意:给你一个由a和b组成的字符串,要......
  • Codeforces 1335E2 Three Blocks Palindrome (hard version)
    链接难度:\(\texttt{1800}\)\(T\)组数据。一个序列\(a_{1\simn}\)。定义\([\underbrace{a,a,\dots,a}_{x},\underbrace{b,b,\dots,b}_{y},\underbrace{a,......
  • Codeforces Round #843 (Div. 2) C【思维】
    https://codeforces.com/contest/1775/problem/C题意题意是说,给你n和x,你要求出最小的满足要求的m,使得\(n\)&\((n+1)\)&\((n+2)\)&\(...\)&\(m=x\)若没有满足的输出-1......
  • Codeforces Round #843 (Div. 2) A~E
    A.GardenerandtheCapybaras这道题目就是想让我们输出三个字符串,然后又一个要求就是中间这个字符串具有最值(最大或最小)的字典序这里需要注意一下,这个字符串里面只有a......
  • Educational Codeforces Round 141 (Rated for Div. 2)
    比赛链接;A核心思路:其实我们不要被迷惑了,这就是一个构造题。如果遇到构造题没有思路的话。可以联想经典的构造。也就是一大一小进行构造。然后检查是否可行。//Problem:......
  • Educational Codeforces Round 15
    EducationalCodeforcesRound15https://codeforces.com/contest/7023/6:ABC不会小学数学,基础差前面写的慢A.MaximumIncrease#include<bits/stdc++.h>usingna......
  • Codeforces Round #843 (Div. 2)
    CodeforcesRound#843(Div.2)https://codeforces.com/contest/1775CD都不会写的垃圾罢了A1.GardenerandtheCapybaras(easyversion)#include<bits/stdc++.h>......