11月22日训练题解
题目链接:https://atcoder.jp/contests/abc228/tasks
abc228_a
题意:高桥每天在S点(24小时制)打开他的房间的灯,并在T点关闭。灯亮时日期可能会改变。确定灯是否在X点后30分钟亮起。
题解:按题目叙述模拟即可 (说句实话细节比较多 直接看代码吧)
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <fstream>
#include <climits>using namespace std;
typedef long long ll;#define pi acos(-1.0)#define oula \bool notprime[1000010]; \int primes[1000010]; \void get_prime() \{ \notprime[1] = true; \for (int i = 2; i < 1000010; ++i) \if (!notprime[i]) \{ \primes[++primes[0]] = i; \for (long long j = (long long)i * i; j < 1000010; j += i) \notprime[j] = true; \} \};#define ksm \inline ll qpow(ll x, ll a) \{ \ll ret = 1, k = x; \for (; a; a >>= 1, k = k * k) \if (a & 1) \ret = ret * k; \return ret; \}#define gcdxy \ll gcd(ll a, ll b) \{ \if (a < b) \swap(a, b); \if (b == 0) \return a; \else \return gcd(a % b, b); \}#define fread \inline ll read() \{ \char ch = getchar(); \ll x = 0, f = 1; \while (ch < '0' || ch > '9') \{ \if (ch == ' - ') \f = -1; \ch = getchar(); \} \while ('0' <= ch && ch <= '9') \{ \x = x * 10 + int(ch - '0'); \ch = getchar(); \} \return x * f; \}#define xor_ \ll xor_n(ll n) \{ \ll t = n & 3; \if (t & 1) \return t / 2ll ^ 1; \return t / 2ll ^ n; \}#define exgcd_ \ll exgcd(ll a, ll b, ll &x, ll &y) \{ \if (b == 0) \{ \x = 1; \y = 0; \return a; \} \ll r = exgcd(b, a % b, x, y); \ll t = x; \x = y; \y = t - a / b * y; \return r; \}
#define mksm \int mod = 1e9 + 7; \inline ll mqpow(ll x, ll a) \{ \ll ret = 1, k = x; \for (; a; a >>= 1, k = k * k % mod) \if (a & 1) \ret = ret * k % mod; \return ret; \}void exgcd_e(ll a, ll b, ll &d, ll &x, ll &y)
{if (!b){d = a;x = 1;y = 0;}else{exgcd_e(b, a % b, d, y, x);y -= x * (a / b);}
}//oula
ksm gcdxy fread xor_ exgcd_ mksmll dp[1100];int main(void) {// ifstream cin;// fstream cout;// cin.open("input.txt", ios::in);// cout.open("ans.txt", ios::out);int n,k,x;cin >> n >> k >> x;if(n > k)k += 24;if(x < n)x += 24;if(n <= x && k > x)cout << "Yes" << endl;elsecout << "No" << endl;return 0;
}/*4
3
1 3 4
5
1 2 5 7 4
1
1
3
69 6969 696969-1 1 4 0 -5 1 8 0 -9 1 12 0
1 2 3 4 5 6 7 8 9 10 11 123 1 -2 2
1 2 3 42 0 -3 1 6 0 -7 1
1 2 3 4 5 6 7 83 2 -4 -2 0
7 6 2 45 4 2
*/
abc228_b
题意:高桥有N个朋友。有一天,高桥不小心让他的一个朋友,朋友X知道了他可耻的秘密。
对于每个i=1,2,…,N,当朋友第i知道秘密时,他/她将与朋友Ai分享, 如果朋友 Ai 不知道这个秘密。
有多少高桥的朋友最终会知道这个秘密?
题解:说句实话这个题我一开始读假了,就是翻译没清楚,但是翻译过来之后发现,对于X开始寻找找到一个已经告诉过的人停止即可
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <fstream>
#include <climits>using namespace std;
typedef long long ll;#define pi acos(-1.0)#define oula \bool notprime[1000010]; \int primes[1000010]; \void get_prime() \{ \notprime[1] = true; \for (int i = 2; i < 1000010; ++i) \if (!notprime[i]) \{ \primes[++primes[0]] = i; \for (long long j = (long long)i * i; j < 1000010; j += i) \notprime[j] = true; \} \};#define ksm \inline ll qpow(ll x, ll a) \{ \ll ret = 1, k = x; \for (; a; a >>= 1, k = k * k) \if (a & 1) \ret = ret * k; \return ret; \}#define gcdxy \ll gcd(ll a, ll b) \{ \if (a < b) \swap(a, b); \if (b == 0) \return a; \else \return gcd(a % b, b); \}#define fread \inline ll read() \{ \char ch = getchar(); \ll x = 0, f = 1; \while (ch < '0' || ch > '9') \{ \if (ch == ' - ') \f = -1; \ch = getchar(); \} \while ('0' <= ch && ch <= '9') \{ \x = x * 10 + int(ch - '0'); \ch = getchar(); \} \return x * f; \}#define xor_ \ll xor_n(ll n) \{ \ll t = n & 3; \if (t & 1) \return t / 2ll ^ 1; \return t / 2ll ^ n; \}#define exgcd_ \ll exgcd(ll a, ll b, ll &x, ll &y) \{ \if (b == 0) \{ \x = 1; \y = 0; \return a; \} \ll r = exgcd(b, a % b, x, y); \ll t = x; \x = y; \y = t - a / b * y; \return r; \}
#define mksm \int mod = 1e9 + 7; \inline ll mqpow(ll x, ll a) \{ \ll ret = 1, k = x; \for (; a; a >>= 1, k = k * k % mod) \if (a & 1) \ret = ret * k % mod; \return ret; \}void exgcd_e(ll a, ll b, ll &d, ll &x, ll &y)
{if (!b){d = a;x = 1;y = 0;}else{exgcd_e(b, a % b, d, y, x);y -= x * (a / b);}
}//oula
ksm gcdxy fread xor_ exgcd_ mksmint a[1000010];
int pos[1000010];int main(void) {// ifstream cin;// fstream cout;// cin.open("input.txt", ios::in);// cout.open("ans.txt", ios::out);int n, k;cin >> n >> k;for (int i = 1; i <= n; i++)cin >> a[i];int ans = 0;while(!pos[k]){pos[k] = 1;k = a[k];ans++;}cout << ans << endl;return 0;
}/*4
3
1 3 4
5
1 2 5 7 4
1
1
3
69 6969 696969-1 1 4 0 -5 1 8 0 -9 1 12 0
1 2 3 4 5 6 7 8 9 10 11 123 1 -2 2
1 2 3 42 0 -3 1 6 0 -7 1
1 2 3 4 5 6 7 83 2 -4 -2 0
7 6 2 45 4 2
*/
abc228_c
题意:N学生参加为期4天的考试。每天有300分的考试,总共1200分。
前三天的考试已经结束,第四天就要开始了。这个第i名学生(1≤i≤N) 有P(i,j )为i第j天的积分(1≤j≤3).
对于每个学生,确定他/她是否有可能在第四天之后进入前K名。
在这里,第四天之后的学生排名定义为四天内总分高于该学生的学生人数加1。
题解:这道题可以化简为第分数k大之后的学生加上三百分是否可以大于等于第k大的分数
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <fstream>
#include <climits>using namespace std;
typedef long long ll;#define pi acos(-1.0)#define oula \bool notprime[1000010]; \int primes[1000010]; \void get_prime() \{ \notprime[1] = true; \for (int i = 2; i < 1000010; ++i) \if (!notprime[i]) \{ \primes[++primes[0]] = i; \for (long long j = (long long)i * i; j < 1000010; j += i) \notprime[j] = true; \} \};#define ksm \inline ll qpow(ll x, ll a) \{ \ll ret = 1, k = x; \for (; a; a >>= 1, k = k * k) \if (a & 1) \ret = ret * k; \return ret; \}#define gcdxy \ll gcd(ll a, ll b) \{ \if (a < b) \swap(a, b); \if (b == 0) \return a; \else \return gcd(a % b, b); \}#define fread \inline ll read() \{ \char ch = getchar(); \ll x = 0, f = 1; \while (ch < '0' || ch > '9') \{ \if (ch == ' - ') \f = -1; \ch = getchar(); \} \while ('0' <= ch && ch <= '9') \{ \x = x * 10 + int(ch - '0'); \ch = getchar(); \} \return x * f; \}#define xor_ \ll xor_n(ll n) \{ \ll t = n & 3; \if (t & 1) \return t / 2ll ^ 1; \return t / 2ll ^ n; \}#define exgcd_ \ll exgcd(ll a, ll b, ll &x, ll &y) \{ \if (b == 0) \{ \x = 1; \y = 0; \return a; \} \ll r = exgcd(b, a % b, x, y); \ll t = x; \x = y; \y = t - a / b * y; \return r; \}
#define mksm \int mod = 1e9 + 7; \inline ll mqpow(ll x, ll a) \{ \ll ret = 1, k = x; \for (; a; a >>= 1, k = k * k % mod) \if (a & 1) \ret = ret * k % mod; \return ret; \}void exgcd_e(ll a, ll b, ll &d, ll &x, ll &y)
{if (!b){d = a;x = 1;y = 0;}else{exgcd_e(b, a % b, d, y, x);y -= x * (a / b);}
}//oula
ksm gcdxy fread xor_ exgcd_ mksmint main(void) {// ifstream cin;// fstream cout;// cin.open("input.txt", ios::in);// cout.open("ans.txt", ios::out);int n, k;cin >> n >> k;vector<int> a;vector<int> b;for(int i = 0; i < n ; i++){int x,y,z;cin >> x >> y >> z;a.push_back(x+y+z);}b = a;sort(a.begin(),a.end(), greater<int>());for(int i = 0; i < n ; i++){if(a[k-1]-300 > b[i])cout << "No" << endl;elsecout << "Yes" << endl;}
}/*4
3
1 3 4
5
1 2 5 7 4
1
1
3
69 6969 696969-1 1 4 0 -5 1 8 0 -9 1 12 0
1 2 3 4 5 6 7 8 9 10 11 123 1 -2 2
1 2 3 42 0 -3 1 6 0 -7 1
1 2 3 4 5 6 7 83 2 -4 -2 0
7 6 2 45 4 2
*/
题目链接:https://atcoder.jp/contests/arc129/tasks
arc129_a
题意:给定的是整数N、L和R。计算满足以下两个条件的整数x的数量。
L≤x≤R
(x⊕N)<N 其中的⊕为按位XOR。
题解:(我先抱怨一下我自己,因为自己犯病了,没去想到l和r在同一个2的n次方区间然后影响了这场比赛,比赛直接爆零。)本题直接枚举每个二的n次方,判断l之前有多少个数和n异或比n小和r之前有多少个数和n异或比n小,最后r区间减去l区间即可,算的时候要注意一下不能暴力枚举,
如果去手写几个样例可以想到一个规律n的r位二进制为1时,在r位之前的所有数都可以异或比n小。
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <fstream>
#include <climits>using namespace std;
typedef long long ll;#define pi acos(-1.0)#define oula \bool notprime[1000010]; \int primes[1000010]; \void get_prime() \{ \notprime[1] = true; \for (int i = 2; i < 1000010; ++i) \if (!notprime[i]) \{ \primes[++primes[0]] = i; \for (long long j = (long long)i * i; j < 1000010; j += i) \notprime[j] = true; \} \};#define ksm \inline ll qpow(ll x, ll a) \{ \ll ret = 1, k = x; \for (; a; a >>= 1, k = k * k) \if (a & 1) \ret = ret * k; \return ret; \}#define gcdxy \ll gcd(ll a, ll b) \{ \if (a < b) \swap(a, b); \if (b == 0) \return a; \else \return gcd(a % b, b); \}#define fread \inline ll read() \{ \char ch = getchar(); \ll x = 0, f = 1; \while (ch < '0' || ch > '9') \{ \if (ch == ' - ') \f = -1; \ch = getchar(); \} \while ('0' <= ch && ch <= '9') \{ \x = x * 10 + int(ch - '0'); \ch = getchar(); \} \return x * f; \}#define xor_ \ll xor_n(ll n) \{ \ll t = n & 3; \if (t & 1) \return t / 2ll ^ 1; \return t / 2ll ^ n; \}#define exgcd_ \ll exgcd(ll a, ll b, ll &x, ll &y) \{ \if (b == 0) \{ \x = 1; \y = 0; \return a; \} \ll r = exgcd(b, a % b, x, y); \ll t = x; \x = y; \y = t - a / b * y; \return r; \}
#define mksm \int mod = 1e9 + 7; \inline ll mqpow(ll x, ll a) \{ \ll ret = 1, k = x; \for (; a; a >>= 1, k = k * k % mod) \if (a & 1) \ret = ret * k % mod; \return ret; \}void exgcd_e(ll a, ll b, ll &d, ll &x, ll &y)
{if (!b){d = a;x = 1;y = 0;}else{exgcd_e(b, a % b, d, y, x);y -= x * (a / b);}
}//oula
ksm gcdxy fread xor_ exgcd_ mksmll a[100];int main(void) {// ifstream cin;// fstream cout;// cin.open("input.txt", ios::in);// cout.open("ans.txt", ios::out);for(ll i = 0; i < 63 ;i++){a[i] = 1ll << i;}ll n,l,r;cin >> n >> l >> r;ll ans1 = 0;ll ans2 = 0;l --;for(ll i = 0; i < 63 ; i++){if((n ^ a[i]) < n && l >= a[i]){if(l > a[i + 1])ans1 += a[i];elseans1 += l % a[i] + 1;}//cout << ans <<" " << a[i] << endl;}for(ll i = 0; i < 63 ; i++){if((n ^ a[i]) < n && r >= a[i]){if(r > a[i + 1])ans2 += a[i];elseans2 += r % a[i] + 1;}//cout << ans <<" " << a[i] << endl;}// cout << ans << endl;cout << ans2 - ans1 <<endl;return 0;
}/*4
3
1 3 4
5
1 2 5 7 4
1
1
3
69 6969 696969-1 1 4 0 -5 1 8 0 -9 1 12 0
1 2 3 4 5 6 7 8 9 10 11 123 1 -2 2
1 2 3 42 0 -3 1 6 0 -7 1
1 2 3 4 5 6 7 83 2 -4 -2 0
7 6 2 45 4 2
*/
arc129_b
题意:对于整数l、r和x(l≤r) ,让我们定义dist(l,r,x)如下。
如果 x < l: dist(l,r,x) = l−x
如果 l ≤ x ≤ r: dist(l,r,x) = 0
如果 r < x: dist(l,r,x) = x − r
给定N对整数,其第i个为(Li,Ri). 每个k=1,2,⋯,N、 解决以下问题。让我们自由选择一个整数x并计算max(dist(L1,R1,x) ,dist(L2,R2,x) ,,⋯,区(Lk,Rk,x) )。请找到此值的最小可能值。
题解: 对于每一次都找到他当前最大的左区间和最小的右区间即可,因为 如果lmax<rmin的时候,可以让这个数放在一个l和一个r之间 结果为0
其他的情况就是取两个数中点的向上取整最小
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <fstream>
#include <climits>using namespace std;
typedef long long ll;#define pi acos(-1.0)#define oula \bool notprime[1000010]; \int primes[1000010]; \void get_prime() \{ \notprime[1] = true; \for (int i = 2; i < 1000010; ++i) \if (!notprime[i]) \{ \primes[++primes[0]] = i; \for (long long j = (long long)i * i; j < 1000010; j += i) \notprime[j] = true; \} \};#define ksm \inline ll qpow(ll x, ll a) \{ \ll ret = 1, k = x; \for (; a; a >>= 1, k = k * k) \if (a & 1) \ret = ret * k; \return ret; \}#define gcdxy \ll gcd(ll a, ll b) \{ \if (a < b) \swap(a, b); \if (b == 0) \return a; \else \return gcd(a % b, b); \}#define fread \inline ll read() \{ \char ch = getchar(); \ll x = 0, f = 1; \while (ch < '0' || ch > '9') \{ \if (ch == ' - ') \f = -1; \ch = getchar(); \} \while ('0' <= ch && ch <= '9') \{ \x = x * 10 + int(ch - '0'); \ch = getchar(); \} \return x * f; \}#define xor_ \ll xor_n(ll n) \{ \ll t = n & 3; \if (t & 1) \return t / 2ll ^ 1; \return t / 2ll ^ n; \}#define exgcd_ \ll exgcd(ll a, ll b, ll &x, ll &y) \{ \if (b == 0) \{ \x = 1; \y = 0; \return a; \} \ll r = exgcd(b, a % b, x, y); \ll t = x; \x = y; \y = t - a / b * y; \return r; \}
#define mksm \int mod = 1e9 + 7; \inline ll mqpow(ll x, ll a) \{ \ll ret = 1, k = x; \for (; a; a >>= 1, k = k * k % mod) \if (a & 1) \ret = ret * k % mod; \return ret; \}void exgcd_e(ll a, ll b, ll &d, ll &x, ll &y)
{if (!b){d = a;x = 1;y = 0;}else{exgcd_e(b, a % b, d, y, x);y -= x * (a / b);}
}//oula
ksm gcdxy fread xor_ exgcd_ mksmll a[100];int main(void) {// ifstream cin;// fstream cout;// cin.open("input.txt", ios::in);// cout.open("ans.txt", ios::out);int q;cin >> q;int maxl = 0,minr = INT_MAX;while(q--){int l, r;cin >> l >> r;maxl = max(maxl, l);minr = min(minr, r);if(maxl < minr)cout << 0 << endl;elsecout << (maxl - minr - 1) / 2 + 1 << endl;}return 0;
}/*4
3
1 3 4
5
1 2 5 7 4
1
1
3
69 6969 696969-1 1 4 0 -5 1 8 0 -9 1 12 0
1 2 3 4 5 6 7 8 9 10 11 123 1 -2 2
1 2 3 42 0 -3 1 6 0 -7 1
1 2 3 4 5 6 7 83 2 -4 -2 0
7 6 2 45 4 2
*/
11月22日训练题解相关推荐
- 11月22日弹性计算跟您在广州不见不散
11月22日,广州云栖大会,弹性计算针对广州专场诚邀各位嘉宾亲临 时间:2017年11月22日,13:30 地点:广州香格里拉酒店三层满江红厅 弹性计算与网络专场特意申请20张云栖大会电子商务票针对企 ...
- 11月22日北京.net俱乐部活动ppt下载以及11月19日微软西格玛IE8开发讲座ppt下载
11月22日北京.net俱乐部活动ppt下载以及11月19日微软西格玛IE8开发讲座ppt下载 请点击下面的连接下载 [url]http://cid-b10793e754ad25f7.skydrive ...
- B站哔哩哔哩:11 月 22 日上午九时正起恢复在香港联交所买卖
IT之家 11 月 19 日消息,哔哩哔哩今日晚间发布公告称,本公司已向香港联交所申请本公司的 Z 类普通股于 2021 年 11 月 22 日上午九时正起恢复在香港联交所买卖. 哔哩哔哩今日发布公告 ...
- 分享Silverlight/WPF/Windows Phone一周学习导读(11月22日-28日)
分享Silverlight, WPF, Windows Phone 7一周学习导读系列,11月22日-11月28日. 本周Silverlight学习资源更新: Silverlight中的TextBox ...
- 倩女幽魂手游服务器维护多久,倩女幽魂手游11月22日在线维护公告
亲爱的玩家: <倩女幽魂>手游将于本周四上午进行在线更新,更新期间无需停服,玩家可照常进行游戏.欢迎您届时体验本周放出的全新内容,祝全体玩家游戏愉快! 本周四在线更新内容如下: 服务器调整 ...
- 珠穆朗玛币王:11月22日是谁丢了136亿美元
珠穆朗玛币王:11月22日是谁丢了136亿美元 昨天,一篇名为"上百亿美元比特币已永久丢失"的微博,在短时间内登上热搜榜. 这篇文章的根源,是区块链数据分析服务提供商Coin Me ...
- 古剑奇谭二服务器维护,《古剑奇谭二》11月22日例行维护更新公告
为不断丰富游戏内容,给各位偃师大人提供良好的游戏环境,我们将于2018年11月22日08:00进行版本更新,此次更新为停服更新,预计维护时间为2个小时.请各位大人注意调整游戏时间,并相互转告.如果预定 ...
- 吃鸡服务器修改测试服,绝地求生测试服更新内容_绝地求生测试服11月22日更新了什么_52pk单机游戏...
第二个测试服务器时间表 第一次发布 - > 11月22日11:00-11月24日16:00 第二次发布 - > 11月28日11:00-11月30日17:00 注:但不一定是可以实际游玩的 ...
- 失业日记 11月22日
11月22日 晴 周日 早上起来吃完早餐,50多的Miss Z 发消息来说今天我们一家出去玩吗?想跟我们出去玩一次.本来我们是打算在家里休息一天的,毕竟现在疫情期间,周边都玩遍了,其他城市又封锁去不了 ...
最新文章
- 利用python实现IP扫描
- 新浪微博推广网站的一些实践体会
- 数据分析利器:XGBoost算法最佳解析
- require(),include(),require_once()和include_once()区别
- memcached 和 redis 的区别与选择
- 终极QQ-ZONE技巧
- word中如何去掉页眉横线?
- java if里面并列_多个if语句并列-两个if语句并列-if语句两个并列条件怎么表示
- 香港服务器怎么加速?
- win11/windows重命名时,命名栏只显示一个字符,而看不到全名?据说是系统分辨率和屏幕分辨率不匹配造成的?但如何解决呢?
- 如何录制一个小的 gif
- 并行多核体系结构基础 Yan Solihin 第4章 针对链式数据结构的并行 摘录
- Deep Supervision:深度监督(2014)+DHM
- 实现Linux下的cp命令
- redhat7安装yum
- 在已有项目中集成mars3d注意事项(vue3和vue2技术栈下)
- 中国电商早已做到的服务,美国电商如今才达成,中国互联网引领全球创新
- 范围——项目规模之人员数量
- 字符串替换^和|字符
- 自媒体神器,一天可以批量剪辑几百个视频,还能批量采集视频素材