SDUT 2022 summer team contest 5th(for 21)

E - Fractions

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

InputcopyOutputcopy
5 8 3 6
16

Sample 2

InputcopyOutputcopy
2018 2019 2018 2019
2

一开始ans没开longlong wa了两发

/*Where there is light, in my heart.*/
/*SUMMER_TRAINING*/
#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <queue>
#include <algorithm>
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 unmap(a,b) unordered_map<a,b>
#define unset(a) unordered_set<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<PII,vector<PII>,greater<PII> >
typedef double db;
typedef pair<int,int> PII;
typedef pair<ll,ll> 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;
                         if(kl*i<a) kl++;
                         ll kr=b/i;
//----------------------------------------------------------
                         ll kkl=c/j;
                         if(kkl*j<c) kkl++;
                         ll kkr=d/j;
//----------------------------------------------------------
                         if(kl>kkr||kr<kkl) continue;
                         else{
                              ll Kl=max(kl,kkl);
                              ll Kr=min(kr,kkr);
                              ans+=Kr-Kl+1;
                         }
                    }
               }
          }
     }
     cout<<ans<<endl;
}

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

  1. chooses two of the given points, then
  2. 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

InputcopyOutputcopy
2
3
5
First
Second

Sponsor

博弈 推出sg函数

/*Where there is light, in my heart.*/
/*SUMMER_TRAINING*/
#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <queue>
#include <algorithm>
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 unmap(a,b) unordered_map<a,b>
#define unset(a) unordered_set<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<PII,vector<PII>,greater<PII> >
typedef double db;
typedef pair<int,int> PII;
typedef pair<ll,ll> 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

InputcopyOutputcopy
abc
3
NO

Sample 2

InputcopyOutputcopy
abba
1
YES

 

签到 判本身是不是回文就行 

/*Where there is light, in my heart.*/
/*SUMMER_TRAINING*/
#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <queue>
#include <algorithm>
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 unmap(a,b) unordered_map<a,b>
#define unset(a) unordered_set<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<PII,vector<PII>,greater<PII> >
typedef double db;
typedef pair<int,int> PII;
typedef pair<ll,ll> 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"<<endl;
     else cout<<"NO"<<endl;
}

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

InputcopyOutputcopy
2 100 1
10 5
5 10
145

Sample 2

InputcopyOutputcopy
4 100 2
30 30
49 2
50 50
20 10
/*Where there is light, in my heart.*/
/*SUMMER_TRAINING*/
#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <queue>
#include <algorithm>
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 unmap(a,b) unordered_map<a,b>
#define unset(a) unordered_set<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<PII,vector<PII>,greater<PII> >
typedef double db;
typedef pair<int,int> PII;
typedef pair<ll,ll> 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<n;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<<Min<<endl;
}

signed main(){
     int t;
     //cin>>t;
     t=1;
     while(t--){
          solve();
     }
}
//made by melody 20220801

 总结:后期没一块把J K写出来很遗憾  有点累了emm(摆

配合渐渐找回来了 希望越打越好 加油

### SDUT PTA 编程题解与在线评测系统使用说明 #### 关于SDUT PTA在线评测系统的概述 SDUT PTA(Programming Teaching Assistant)是一个面向学生学习编程的在线评测平台,主要用于支持山东理工大学计算机科学及相关专业的课程教学。该平台提供了丰富的练习题目以及自动化的测试机制,帮助学生巩固所学的知识并提升实际编程能力[^1]。 #### 如何使用SDUT PTA在线评测系统? 以下是关于如何有效利用SDUT PTA进行编程训练的关键要点: 1. **注册账号** 学生需通过学校指定的方式完成账户注册,并登录到对应的班级页面参与作业提交和考试活动。 2. **熟悉界面布局** 登录后可以看到左侧导航栏包含了“我的作业”、“公开试题”等功能模块;右侧则显示具体任务列表及其状态信息(未做/已交/得分情况)。点击某道题目可以查看其详细描述、样例输入输出以及其他提示内容[^2]。 3. **编写代码并调试** 对于像“计算1到n的和”的简单问题,可以直接采用如下C语言实现方式来解决: ```c #include<stdio.h> int main(){ int n, sum=0; scanf("%d",&n); for(int i=1;i<=n;i++) { sum +=i; } printf("%d\n",sum); return 0; } ``` 此段代码实现了基本的功能需求——读取用户输入的一个正整数值`n`,并通过循环累加得到最终的结果输出。 4. **提交解决方案** 完成本地开发环境中的编码工作之后,在网页端找到对应位置上传源文件或者直接粘贴文本框内的代码片段即可发起评测请求。注意遵循每道题目的特殊约束条件比如时间复杂度限制等规定。 5. **分析反馈结果** 提交完成后会迅速获得运行状况报告,如果存在错误,则应仔细阅读报错消息重新审视自己的逻辑是否存在漏洞再尝试修正直至完全正确为止。 #### 常见问题解答 对于初学者来说可能会遇到一些困惑之处,下面列举几个典型场景供参考: - 如果发现即使按照标准答案复制也得不到满分怎么办?可能是因为忽略了某些边界情形处理或者是格式化方面的小失误所致。 - 当面对较复杂的算法类挑战不知道从哪里下手时建议先梳理清楚思路画流程图辅助理解后再动手实践。 - 还有就是保持耐心多试几次不要轻易放弃因为每一次失败都是成长的机会! ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值