Codeforces Beta Round #107(Div2)
B.Phone Numbers
思路:就是简单的结构体排序,只是这里有一个技巧,就是结构体存储的时候,直接存各种类型的电话的数量是多少就行,在读入电话的时候,既然号码是一定的,那么就直接按照格式%c读取就好,在比较的时候也容易比较,直接比较ASCII码就行
代码:
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
using namespace std;
struct people{
int num;
char s[100];
int t=0,p=0,c=0;
}a[1500];
bool cmpt(people a,people b){
if(a.t==b.t){
return a.num<b.num;
}
return a.t>b.t;
}
bool cmpp(people a,people b){
if(a.p==b.p){
return a.num<b.num;
}
return a.p>b.p;
}
bool cmpc(people a,people b){
if(a.c==b.c){
return a.num<b.num;
}
return a.c>b.c;
}
int main(){
int t;
scanf("%d",&t);
for(int i=0;i<t;i++){
a[i].num=i;
int n;
scanf("%d %s",&n,&a[i].s);
int t=0;
int p=0;
int cc=0; for(int j=0;j<n;j++){
char b,c,d,e,f,g;
char s;
getchar();
scanf("%c%c",&b,&c);
scanf("%c",&s);
scanf("%c%c",&d,&e);
scanf("%c",&s);
scanf("%c%c",&f,&g);
if(b==c&&c==d&&d==e&&e==f&&f==g){
t++;
}else if(b>c&&c>d&&d>e&&e>f&&f>g){
p++;
}else{
cc++;
}
}
a[i].p=p;
a[i].t=t;
a[i].c=cc;
}
/*for(int i=0;i<t;i++){
printf("%d %d %d\n",a[i].t,a[i].p,a[i].c);
}*/
int tt=0;
int p=0;
int c=0;
int sump=0,sumt=0,sumc=0;
sort(a,a+t,cmpt);
tt=a[0].t;
for(int i=0;i<t;i++){
if(a[i].t==tt){
sumt++;
}
}
printf("If you want to call a taxi, you should call: ");
for(int i=0;i<sumt;i++){
printf("%s",a[i].s);
if(i<sumt-1){
printf(", ");
}
}
printf(".\n");
sort(a,a+t,cmpp);
p=a[0].p;
for(int i=0;i<t;i++){
if(a[i].p==p){
sump++;
}
}
printf("If you want to order a pizza, you should call: ");
for(int i=0;i<sump;i++){
printf("%s",a[i].s);
if(i<sump-1){
printf(", ");
}
}
printf(".\n");
sort(a,a+t,cmpc);
c=a[0].c;
for(int i=0;i<t;i++){
if(a[i].c==c){
sumc++;
}
}
printf("If you want to go to a cafe with a wonderful girl, you should call: ");
for(int i=0;i<sumc;i++){
printf("%s",a[i].s);
if(i<sumc-1){
printf(", ");
}
}
printf(".");
}
C.Win or Freeze
思路:其实最多两局,如果给定的这个数质因子大于2或者是质数,那么就是1赢,1直接选定两个质因子的乘积就能确保自己赢,剩下的情况就是2赢
代码:
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<vector>
using namespace std;
vector <pair<__int64, __int64> > divide(__int64 x) {
vector <pair<__int64, __int64> > v;
for (int i = 2; i <= x / i; ++i)
if (x % i == 0) {
int s = 0;
while (x % i == 0) x /= i, s++;
v.emplace_back(i, s);
}
if (x > 1) v.emplace_back(x, 1);
return v;
} /*vector<__int64> get_divisors(__int64 x) {
vector<__int64> res;
for (__int64 i = 1; i <= x / i; ++i)
if (x % i == 0) {
res.push_back(i);
if (i != x / i) res.push_back(x / i);
}
sort(res.begin(), res.end());
return res;
}*/
inline bool isprime(long long n) {
if (n < 2) return false;
if (n == 2) return true;
if (n % 2 == 0) return false;
for (long long i = 3; i <= n / i; i += 2)
if (n % i == 0) return false;
return true;
} int main(){
__int64 num;
int flag=0;
scanf("%I64d",&num);
if(num==1){
printf("1\n");
printf("0\n");
return 0;
}else if(isprime(num)==true){
printf("1\n");
printf("0\n");
return 0;
}
vector<pair<__int64,__int64>> v;
v=divide(num);
__int64 len=v.size();
__int64 sum=0;
__int64 sump=1;
int f=0;
for(__int64 i=0;i<len;i++){
__int64 se=v.back().second;
__int64 fi=v.back().first;
v.pop_back();
sum+=se;
if(f<2){
if(se>=2&&f==0){
f++;
f++;
sump*=fi;
sump*=fi;
}else if(se<2){
sump*=fi;
f++;
}else{
sump*=fi;
f++;
}
}
}
if(sum<=2){
printf("2\n");
}else{
printf("1\n");
printf("%I64d\n",sump);
}
}
D - Quantity of Strings
思路:主要分为k>n,k=n,k<n的情况,见代码,wa掉这么多主要是前两种考虑出了问题
代码:
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<vector>
using namespace std;
const long long int modd=1e9+7;
int main(){
int n,m,k;
scanf("%d %d %d",&n,&m,&k);
__int64 sum=0;
if(k<n){
if(k%2==0){
sum+=m;
/* if(k!=2){
sum+=((m-1)*m)%modd;
}*/
}else{
if(k==1){
__int64 num=1;
for(int i=0;i<n;i++){
num=(num*m)%modd;
num%=modd;
}
sum+=num;
}else{
__int64 num=1; sum+=((m-1)*m)%modd; sum+=m;
}
}
}else if(k==n){
if(k%2==0){
__int64 num=1;
for(int i=0;i<n/2;i++){
num=(num*m)%modd;
num%=modd;
}
sum+=num;
}else{
__int64 num=1;
for(int i=0;i<(n/2)+1;i++){
num=(num*m)%modd;
num%=modd;
}
sum+=num;
}
}else{
__int64 num=1;
for(int i=0;i<n;i++){
num=(num*m)%modd;
num%=modd;
}
sum+=num;
}
printf("%I64d\n",sum);
}
Codeforces Beta Round #107(Div2)的更多相关文章
- Codeforces Beta Round #73(Div2)
A - Chord 题意:就是环中有12个字符,给你三个字符,判断他们之间的间隔,如果第一个和第二个间隔是3并且第二个和第三个间隔是4,那么就输出minor,如果第一个和第二个间隔是4并且第二个和第三 ...
- Codeforces Beta Round #94 div2 D 优先队列
B. String time limit per test 2 seconds memory limit per test 256 megabytes input standard input out ...
- Codeforces Beta Round #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- Codeforces Beta Round #62 题解【ABCD】
Codeforces Beta Round #62 A Irrational problem 题意 f(x) = x mod p1 mod p2 mod p3 mod p4 问你[a,b]中有多少个数 ...
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
- Codeforces Beta Round #13 C. Sequence (DP)
题目大意 给一个数列,长度不超过 5000,每次可以将其中的一个数加 1 或者减 1,问,最少需要多少次操作,才能使得这个数列单调不降 数列中每个数为 -109-109 中的一个数 做法分析 先这样考 ...
- Codeforces Beta Round #79 (Div. 2 Only)
Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...
- Codeforces Beta Round #77 (Div. 2 Only)
Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...
- Codeforces Beta Round #76 (Div. 2 Only)
Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...
随机推荐
- IPFS是什么?IPFS与Filecoin有什么关系?
Filecoin 基于 IPFS 的去中心化存储网络,是 IPFS 上唯一的激励层,是一个基于区块链技术发行的通证.Filecoin 翻译过来就是文件币,简称为 FIL. 在 FIlecoin 网络中 ...
- Hexagon HDU - 6862
题目链接:https://vjudge.net/problem/HDU-6862 题意: 由六边形组成的圆形图案,要求不重复走遍历每一个小六边形. 思路:https://www.cnblogs.com ...
- JVM虚拟机知识问答总结(简单复习,快速回忆!)
写在最前面 这个项目是从20年末就立好的 flag,经过几年的学习,回过头再去看很多知识点又有新的理解.所以趁着找实习的准备,结合以前的学习储备,创建一个主要针对应届生和初学者的 Java 开源知识项 ...
- Vim快速使用教程
Vim Vim是从vi发展出来的一个文本编辑器.代码补完.编译及错误跳转等方便编程的功能特别丰富. Vi/Vim的使用 基本上分为三种模式,分别是命令模式(commad mode),输入模式(Inse ...
- Qt开发技术:图形视图框架(一)基本介绍
前话 使用到Qt的视图框架. Qt视图框架介绍 简介 图形视图框架(The Graphic View Framework)用于管理和与大量定制的二维图形项目交互,以及用于可视化项目的视图小 ...
- 【笔记】《Redis设计与实现》chapter12 事件
12.1 文件事件 Redis基于Reactor模式开发了自己的网络事件处理器:这个处理器被称为文件时间处理器: 文件时间处理器使用IO多路复用程序来同时监听多个套接字,并根据套接字目前执行的任务来为 ...
- Ananagrams UVA - 156
Most crossword puzzle fans are used to anagrams - groups of words with the same letters in differe ...
- N 皇后-力扣解题
n 皇后问题 研究的是如何将 n 个皇后放置在 n*n 的棋盘上,并且使皇后彼此之间不能相互攻击. 给你一个整数 n ,返回所有不同的 n 皇后问题 的解决方案. 每一种解法包含一个不同的 n 皇后问 ...
- Scrum Meeting 目录 && alpha 第一次Scrum Meeting博客
是兄弟就来摸鱼小组 Scrum Meeting 博客汇总 一.Alpha阶段 标号 标题 1 [alpha]第一次Scrum Meeting(见本文) 二.Beta阶段 会议安排 时间 4月23日8时 ...
- 2021S软件工程——个人阅读作业2
2021S软件工程--个人阅读作业2 项目 内容 这个作业属于哪个课程 2021春季软件工程(罗杰 任建) 这个作业的要求在哪里 个人阅读作业#2 我在这个课程的目标是 了解并熟悉软件开发的具体流程, ...