About 44 days are left before College Scholastic Ability Test is held. This exam aims to measure students' achievement of National Curriculum standards and scholastic ability required for college education. (http://www.kice.re.kr/sub/info.do?m=0205&s=english)
One of the subjects covered by this test is Mathematics, which consists of 21 multiple choice questions and 9 short-answer questions. The answer of each short-answer question is guaranteed to be a unique positive integer below 1 000, as you can see from the answer sheet below.
However, the organizers might want to give students short-answer questions with non-integer answers, such as 2\sqrt{3}23 or \frac{5}{3}35. Usually, the workaround is to write the answer in a canonical form, and then sum up all the integers inside that form and ask students to write that number instead.
In particular, when the answer is a positive rational number \frac{a}{b}ba, the organizers usually ask students to reduce it and sum up the numerator and the denominator of the reduced fraction. For example, when the answer is \frac{18}{10}1018, the student should reduce it to \frac{9}{5}59 and write the final answer as 9 + 5 = 149+5=14.
However, when the answer is \frac{521}{500}500521, the reduced fraction is also \frac{521}{500}500521, so the student should write the final answer as 521 + 500 = 1021521+500=1021. But this shouldn't happen, since all the answers for the short-answer questions are below 1 000. To avoid this situation, the organizers should make sure that after reducing the fraction, the sum of the numerator and the denominator shouldn't exceed 999999. Let's call such fractions as Suneung Fractions. For example, \frac{1996}{2}21996 and \frac{18}{10}1018 are Suneung fractions, while \frac{1998}{2}21998 and \frac{521}{500}500521 are not.
Suppose that, this year, one of the organizers wrote a problem, and the answer to that problem is \frac{x}{y}yx. Since the problem is not finalized yet, the only thing we know is A \le x \le BA≤x≤B and C \le y \le DC≤y≤D holds, for given A, B, C, DA,B,C,D. The organizers want to know, among all the pairs (x, y)(x,y), how many of \frac{x}{y}yx is a Suneung fraction. Write a program that counts this number.
Input
The first and only line contains four space-separated integers A, B, CA,B,C and DD (1 \le A \le B \le 10^{12}1≤A≤B≤1012, 1 \le C \le D \le 10^{12}1≤C≤D≤1012)
Output
Print the number of integral pairs (x, y)(x,y) (A \le x \le BA≤x≤B, C \le y \le DC≤y≤D), where \frac{x}{y}yx is a Suneung fraction.
Sample 1
Inputcopy | Outputcopy |
---|---|
5 8 3 6 | 16 |
Sample 2
Inputcopy | Outputcopy |
---|---|
2018 2019 2018 2019 | 2 |
一开始ans没开longlong wa了两发
- /*Where there is light, in my heart.*/
- /*SUMMER_TRAINING*/
- #include
- #include
- #include
- #include
- #include
- using namespace std;
- //
- #define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
- //#define INF 0x3f3f3f
- #define ll long long
- #define INF 0x3f3f3f3f
- #define mem(a,b) memset(a,b,sizeof(a))
- #define F first
- #define S second
- #define pb push_back
- #define rep(i, a, b) for (int i = (a); i <= (b); ++i)
- #define _rep(i, a, b) for (int i = (a); i >= (b); --i)
- #define mode 1e4+7
- #define pi acos(-1)
- #define U_queue priority_queue
,greater > - typedef double db;
- typedef pair<int,int> PII;
- typedef pair
PLL; - typedef vector<int> vi;
- const int N = 3e4+5;
- //====================================================//
- void solve(){
- ll a,b,c,d;
- scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
- ll ans=0;
- for(int i=1;i<=998;i++){
- for(int j=1;j<=998;j++){
- if(i+j>999) continue;
- else{
- if(__gcd(i,j)!=1){
- continue;
- }
- else{
- ll kl=a/i;
- ll kr=b/i;
- //----------------------------------------------------------
- ll kkl=c/j;
- if(kkl*j
- ll kkr=d/j;
- //----------------------------------------------------------
- if(kl>kkr||kr
continue; - else{
- ll Kl=max(kl,kkl);
- ll Kr=min(kr,kkr);
- ans+=Kr-Kl+1;
- }
- }
- }
- }
- }
- cout<
- }
-
- signed main(){
- int t;
- //cin>>t;
- t=1;
- while(t--){
- solve();
- }
- }
- //made by melody 202208
F - Game on Plane
You are given NN points on a plane. These points are precisely the set of vertices of some regular NN-gon. Koosaga, an extreme villain, is challenging you with a game using these points. You and Koosaga alternatively take turns, and in each turn, the player
- chooses two of the given points, then
- draws the line segment connecting the two chosen points.
Also, the newly drawn line segment must not intersect with any of the previously drawn line segments in the interior. It is possible for two segments to meet at their endpoints. If at any point of the game, there exists a convex polygon consisting of the drawn line segments, the game ends and the last player who made the move wins.
Given the integer NN, Koosaga is letting you decide who will move first. Your task is decide whether you need to move first or the second so that you can win regardless of Koosaga's moves.
Input
The input consists of many test cases. The first line contains an integer TT (1\leq T\leq 50001≤T≤5000), the number of test cases. Each of the following TT test cases is consisted of one line containing the integer NN (3\leq N\leq 50003≤N≤5000).
Output
For each test case, print one line containing the string First if you need to move first or Second if you need to move second so that you can win regardless of Koosaga's moves.
Sample 1
Inputcopy Outputcopy 2
3
5
First
Second
Sponsor
博弈 推出sg函数
- /*Where there is light, in my heart.*/
- /*SUMMER_TRAINING*/
- #include
- #include
- #include
- #include
- #include
- using namespace std;
- //
- #define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
- //#define INF 0x3f3f3f
- #define ll long long
- #define INF 0x3f3f3f3f
- #define mem(a,b) memset(a,b,sizeof(a))
- #define F first
- #define S second
- #define pb push_back
- #define rep(i, a, b) for (int i = (a); i <= (b); ++i)
- #define _rep(i, a, b) for (int i = (a); i >= (b); --i)
- #define mode 1e4+7
- #define pi acos(-1)
- #define U_queue priority_queue
,greater > - typedef double db;
- typedef pair<int,int> PII;
- typedef pair
PLL; - typedef vector<int> vi;
- const int N = 5010;
- //====================================================//
- //sg=s[j]^s[i-2-j];
- int sg[N],s[N];
- void getSG(){
- //mem(sg,0);
- sg[1]=0;
- sg[2]=1;
- for(int i=3;i<=5000;i++){
- mem(s,0);
- for(int j=0;j<=i-2;j++) s[(sg[j]^sg[i-2-j])]=1;
- for(int j=0;;j++){
- if(!s[j]){
- sg[i]=j;
- break;
- }
- }
- }
- }
- void solve(){
- int n;
- scanf("%d",&n);
- if(sg[n]) puts("First");
- else puts("Second");
- }
-
- signed main(){
- getSG();
- int t;
- scanf("%d",&t);
- while(t--){
- solve();
- }
- }
- //made by melody 20220804
L - Repetitive Palindrome
You are given a string ss consisting of lowercase alphabets, and an integer kk.
Make a new string tt by concatenating kk copies of ss. Determine whether tt is a palindrome, e.g. is the same backward as forward.
Input
The first line contains a string ss consisting of lowercase alphabets. (1 \le |s| \le 2500001≤∣s∣≤250000)
The second line contains an integer kk. (1 \le k \le 10^{18}1≤k≤1018)
Output
If tt is a palindrome, print YES. If not, print NO.
Sample 1
Inputcopy Outputcopy abc
3
NO
Sample 2
Inputcopy Outputcopy abba
1
YES
签到 判本身是不是回文就行
- /*Where there is light, in my heart.*/
- /*SUMMER_TRAINING*/
- #include
- #include
- #include
- #include
- #include
- using namespace std;
- //
- #define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
- //#define INF 0x3f3f3f
- #define ll long long
- #define INF 0x3f3f3f3f
- #define mem(a,b) memset(a,b,sizeof(a))
- #define F first
- #define S second
- #define pb push_back
- #define rep(i, a, b) for (int i = (a); i <= (b); ++i)
- #define _rep(i, a, b) for (int i = (a); i >= (b); --i)
- #define mode 1e4+7
- #define pi acos(-1)
- #define U_queue priority_queue
,greater > - typedef double db;
- typedef pair<int,int> PII;
- typedef pair
PLL; - typedef vector<int> vi;
- const int N = 3e5+5;
- //====================================================//
- void solve(){
- string s;
- int k;
- cin>>s;
- cin>>k;
- //int len=s.size();
- string ss;
- ss=s;
- reverse(s.begin(),s.end());
- if(ss==s) cout<<"YES"<
- else cout<<"NO"<
- }
-
- signed main(){
- int t;
- //cin>>t;
- t=1;
- while(t--){
- solve();
- }
- }
- //made by melody 20220801
M - Coke Challenge
Mr. Jeong really loves coke. He loves so much that he drinks coke everyday without exception. One day, he decided to open a coke contest in Daejeon. To the winner, a box of cokes will be given!
N people participate in the contest. Each participant is given K mL of coke, and the one who finishes his/her coke earliest wins the contest. But it is painful to drink the whole coke in one time, so each person repeats drinking and taking a rest. More specifically, as soon as the contest starts, the ith participant starts to drink for ti seconds, then takes a rest for si seconds, and repeats this process until no more coke remains. Moreover, everyone drinks A mL per second. The contest is over if one of the participants finished his/her coke.
Given the infomation of N participants, determine after how many seconds the contest is finished, since the contest begins.
Input
The input starts with the first line containing three integers N (2 ≤ N ≤ 1000), K (1 ≤ K ≤ 10000), and A (1 ≤ A ≤ 100). The ith of the next N lines contains two integers ti (1 ≤ ti ≤ 100) and si (1 ≤ si ≤ 100), the information of ith participant. K is a multiple of A.
Output
Write a single integer, the answer to the question.
Sample 1
Inputcopy Outputcopy 2 100 1
10 5
5 10
145
Sample 2
Inputcopy Outputcopy 4 100 2
30 30
49 2
50 50
20 10
5
- /*Where there is light, in my heart.*/
- /*SUMMER_TRAINING*/
- #include
- #include
- #include
- #include
- #include
- using namespace std;
- //
- #define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
- //#define INF 0x3f3f3f
- #define ll long long
- #define INF 0x3f3f3f3f
- #define mem(a,b) memset(a,b,sizeof(a))
- #define F first
- #define S second
- #define pb push_back
- #define rep(i, a, b) for (int i = (a); i <= (b); ++i)
- #define _rep(i, a, b) for (int i = (a); i >= (b); --i)
- #define mode 1e4+7
- #define pi acos(-1)
- #define U_queue priority_queue
,greater > - typedef double db;
- typedef pair<int,int> PII;
- typedef pair
PLL; - typedef vector<int> vi;
- const int N = 3e4+5;
- //====================================================//
- int s[N],t[N];
- void solve(){
- int n,k,a;
- cin>>n>>k>>a;
- int Min=INF;
- for(int i=0;i
- cin>>t[i]>>s[i];
- int Sum=k;
- int time=0;
- time+=k/(t[i]*a)*(t[i]+s[i]);
- Sum%=(t[i]*a);
- time+=Sum/a;
- if(Sum==0)
- time-=s[i];
- Min=min(Min,time);
- }
- cout<
- }
-
- signed main(){
- int t;
- //cin>>t;
- t=1;
- while(t--){
- solve();
- }
- }
- //made by melody 20220801
总结:后期没一块把J K写出来很遗憾 有点累了emm(摆
配合渐渐找回来了 希望越打越好 加油
-
相关阅读:
2020年MathorCup数学建模A题无车承运人平台线路定价问题解题全过程(程序+论文)
HTTPS建立连接的过程
vue3 组件与API直接使用,怎样无需import?
centos7.6安装部署gitlab服务器
安卓玩机-----给app加注册码 app加弹窗 云注入弹窗
[附源码]SSM计算机毕业设计ssm新冠疫苗预约接种信息管理JAVA
hadoop测试环境sqoop使用
基于AM335X开发板 ARM Cortex-A8——Acontis EtherCAT主站开发案例
yarn 运行electron
初探UAF漏洞
-
原文地址:https://blog.csdn.net/LanceLSf/article/details/126165232