hdu-1034(模拟+小朋友分糖)】的更多相关文章

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1034 参考文章:https://blog.csdn.net/zyy173533832/article/details/37990885 题意:如果老师要每个小朋友的糖的数目相同,进行如下调整:从0号小朋友开始,将自己的糖的一半分给他右手边的小朋友, 如果糖数是奇数,老师就给他一块糖. 求经过多少次操作得到每个小朋友的糖的数目相同,还有小朋友们糖的数目相同的时候每个小朋友得到多少糖. 思路:模拟,建立…
题目: 题目描述 有 N 个(相同的)糖果,M 个(不同的)小朋友.M 和 N 满足:1≤M≤N≤100000(105).要求:1.每个小朋友都至少有一个糖果.2.不存在正整数 X(X>=2),使得每个小朋友的糖果数都是 X 的倍数.3.糖果不能剩余.求分糖方法总数.答案模 1000000007(109+7) 输入格式 第一行为数据组数:T<=100000.接下来 N 行,每行 2 个如上文所示的正整数 N,M. 输出格式 输出 T 行,每行一个整数,为答案.注意取模! 样例数据 1 输入 […
题目链接 Problem Description A number of students sit in a circle facing their teacher in the center. Each student initially has an even number of pieces of candy. When the teacher blows a whistle, each student simultaneously gives half of his or her can…
题意是一群孩子围成一个圈,每个人把手中的糖果分一半给右边的人,若分过之后手中的糖果数是奇数,则由老师提供一颗糖果给他,问这样传递多少圈所有人的糖果数都能相等,最终每人手里的糖果数是多少. 由于题中已经解释了结果是有限的数,那么就直接模拟,要注意分的时候是从前面的人往后面传递. 代码如下: #include <bits/stdc++.h> using namespace std; ],pre[]; bool judge() { ; i < n; ++i) ]) return false;…
http://acm.hdu.edu.cn/showproblem.php?pid=4891 给出一个文本,问说有多少种理解方式. 1. $$中间的,(s1+1) * (s2+1) * ...*(sn+1), si表示连续的空格数. 2.{}中间,即 | 的个数+1. 就是模拟 #include <iostream> #include <cstring> #include <cstdio> #include <algorithm> #include <…
http://acm.hdu.edu.cn/showproblem.php?pid=5012 模拟出骰子四种反转方式,bfs,最多不会走超过6步 #include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <string> #include <queue> #include <vector> #include <i…
思路: 主要就是模拟这些操作,用链表果断超时.改用堆栈模拟就过了 #include<map> #include<set> #include<stack> #include<cmath> #include<queue> #include<cstdio> #include<vector> #include<string> #include<cstdlib> #include<cstring>…
The Donkey of Gui Zhou Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 389    Accepted Submission(s): 153 Problem Description There was no donkey in the province of Gui Zhou, China. A trouble m…
给出五子棋残局,推断三步内能否分出胜负,玩家为当前该走旗子的颜色,下一步为白棋或黑棋不定. 依照顺序推断就可以: 1:推断棋盘是否合法,并确定玩家颜色 2:推断当前玩家颜色是否有一个必胜点,有玩家则在第一步胜 3:推断还有一方在当前是否有两个必胜点,若有,则玩家在第二步失败 4:BFS出玩家是否存在此方案:随意放置一个位置的前提下,还有一方没有必胜点,且玩家有两个必胜点,则玩家在第三步胜 5:否则3步内无法分出胜负 #include "stdio.h" #include "s…
题目链接 模拟题,直接看代码. £:分数的计算方法,要用double; #include <set> #include <map> #include <cmath> #include <queue> #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; typedef…