首页 > 编程语言 >CCF_201912-1 报数(C++_模拟)

CCF_201912-1 报数(C++_模拟)

时间:2023-06-20 10:07:33浏览次数:48  
标签:temp ++ sum C++ break int 201912 judge CCF


CCF_201912-1 报数(C++_模拟)_复制粘贴

思路

代码可能写的有点啰嗦冗余,写的时候有点急写完一节就直接复制粘贴了蛤蛤蛤,所以导致中间有些代码比较重复。

Code

#include<bits/stdc++.h>//模拟
using namespace std;
int n, sum = 0, a, b, c, d;

bool judge(int s)
{
	int temp = s;
	if (temp % 7 == 0)
		return 0;
	while (temp >= 1)
	{
		if (temp % 10 == 7)
			return 0;
		temp /= 10;
	}
	return 1;
}
int main()
{
	cin >> n;
	for (int i=1;1;i++)
	{
		if (sum == n)
			break;
		if (judge(i))
			sum++;
		else
			a++;
		i++;
		if (sum == n)
			break;
		if (judge(i))
			sum++;
		else
			b++;
		if (sum == n)
			break;
		i++;
		if (judge(i))
			sum++;
		else
			c++;
		if (sum == n)
			break;
		i++;
		if (judge(i))
			sum++;
		else
			d++;
		if (sum == n)
			break;
	}
	cout << a << endl << b << endl << c << endl << d << endl;
	return 0;
}


标签:temp,++,sum,C++,break,int,201912,judge,CCF
From: https://blog.51cto.com/u_16165815/6520475

相关文章

  • 数据结构代码整理_基于邻接表的拓扑排序(C++_DFS_BFS_递归)
    目录Chat图解基于栈实现(dfs)基于队列实现(bfs)基于递归实现(dfs)Chat1.代码所属的类在数据结构代码整理_基于邻接表存储结构的有向图的实现(C++)2.拓扑排序的思想就是不断找入度为0的节点并将其输出并标记,标记后与他相连的节点的入度都会减一,不断进行标记直至所有的节点都被输出为止......
  • Educational Codeforces Round 82 (Rated for Div. 2)_A. Erasing Zeroes(C++_模拟)
    Youaregivenastring.Eachcharacteriseither0or1.Youwantall1’sinthestringtoformacontiguoussubsegment.Forexample,ifthestringis0,1,00111or01111100,thenall1’sformacontiguoussubsegment,andifthestringis0101,100001o......
  • PAT (Advanced Level) Practice_1095 Cars on Campus (30分)(C++_模拟)
    ZhejiangUniversityhas8campusesandalotofgates.Fromeachgatewecancollectthein/outtimesandtheplatenumbersofthecarscrossingthegate.Nowwithalltheinformationavailable,youaresupposedtotell,atanyspecifictimepoint,thenu......
  • P1969 积木大赛(C++_贪心_模拟)
    题目描述春春幼儿园举办了一年一度的“积木大赛”。今年比赛的内容是搭建一座宽度为n的大厦,大厦可以看成由n块宽度为1的积木组成,第i块积木的最终高度需要是。在搭建开始之前,没有任何积木(可以看成n块高度为0的积木)。接下来每次操作,小朋友们可以选择一段连续区间,然后将第第L块到第R......
  • PAT_Advanced Level_1083 List Grades (25分)(C++_快排)
    GivenalistofNstudentrecordswithname,IDandgrade.Youaresupposedtosorttherecordswithrespecttothegradeinnon-increasingorder,andoutputthosestudentrecordsofwhichthegradesareinagiveninterval.InputSpecification:Eachinput......
  • 【蓝桥杯_真题演练】第十届C/C++省赛B组_H-等差数列(C++_gcd_数论)
    ProblemProcess在输入的时候先去重,然后进行排序,至于他们的公差p则需要计算每两个相邻数值之间差值的最大公因数,最终的结果应该是Code#include<bits/stdc++.h>usingnamespacestd;#definelllonglongintn,a[100010],cnt;set<int>s;intgcd(inta,intb){ returnb==......
  • P1062 数列(C++_数论)
    题目描述给定一个正整数k(3≤k≤15),把所有k的方幂及所有有限个互不相等的k的方幂之和构成一个递增的序列,例如,当k=3时,这个序列是:(该序列实际上就是:)请你求出这个序列的第N项的值(用10进制数表示)。例如,对于k=3,N=100,正确答案应该是981。输入格式2个正整数,用一个空格隔开:输出格式1个正整......
  • P1095 守望者的逃离(C++_贪心_模拟/dp)
    题目描述恶魔猎手尤迪安野心勃勃,他背叛了暗夜精灵,率领深藏在海底的娜迦族企图叛变。守望者在与尤迪安的交锋中遭遇了围杀,被困在一个荒芜的大岛上。为了杀死守望者,尤迪安开始对这个荒岛施咒,这座岛很快就会沉下去。到那时,岛上的所有人都会遇难。守望者的跑步速度为17m/s,以这样的速度......
  • PTA_乙级_1006 换个格式输出整数(C++_模拟)
    让我们用字母B来表示“百”、字母S表示“十”,用12…n来表示不为零的个位数字n(<10),换个格式来输出任一个不超过3位的正整数。例如234应该被输出为BBSSS1234,因为它有2个“百”、3个“十”、以及个位的4。输入格式:每个测试输入包含1个测试用例,给出正整数n(<1000)。输......
  • PAT (Advanced Level)_1100 Mars Numbers (20分)(C++_模拟)
    PeopleonMarscounttheirnumberswithbase13:ZeroonEarthiscalled"tret"onMars.Thenumbers1to12onEarthiscalled"jan,feb,mar,apr,may,jun,jly,aug,sep,oct,nov,dec"onMars,respectively.Forthenexthigherdigi......