2017CCPC秦皇岛
热身赛
Time Limit: 1 Second Memory Limit: 65536 KB
Helianthuswolf Co. Ltd. is a multinational “Intestnet” company. Its revenue from global markets grew year by year. Helianthuswolf unveiled its new smartphone Q10 in the spring of 2017.
As a high-end smartphone, Q10 uses UFS2.1 or UFS2.0 or eMMC5.1 for its flash drive. Q10 also uses LPDDR3 or LPDDR4 as its memory, and its CPU does not support DDR3. In order to better show the performance of the Q10, Helianthuswolf reduced the oleophobic coating layer of some smartphones.
Helianthuswolf produces Q10 in two factories. As you see in the following table, the probabilities of the components they use are different. And the use of each component is an independent event.
Flash Drive Memory Oleophobic Layer
UFS2.0 UFS2.1 eMMC5.1 LPDDR3 LPDDR4 Sparse Normal
A 20% 30% 50% 40% 60% 70% 30%
B 30% 50% 20% 70% 30% 40% 60%
Now we get the information of Q10 smartphones produced by one factory. The smartphones are all produced by either factory A or factory B. Please find out which factory is more likely to produce these smartphones.
Input
There are multiple test cases. The first line of the input contains an integer (), indicating the number of test cases. For each test case:
The first line is an integer (), indicating the number of smartphones.
The following lines are the information of the smartphones, each line has three words describing the components.
Output
For each test case, output “A” (without quotes) if it is more likely for factory A to produce these smartphones, output “B” (without quotes) if it is more likely for factory B to produce these smartphones. If it is equally likely for the two factories to produce these smartphones, output “E” (without quotes).
Sample Input
3
1
eMMC5.1 LPDDR4 Sparse
2
UFS2.1 LPDDR3 Sparse
UFS2.0 LPDDR4 Normal
3
UFS2.1 LPDDR3 Sparse
eMMC5.1 LPDDR4 Normal
UFS2.0 LPDDR4 Normal
Sample Output
A
B
E
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define INF 0x3f3f3f3f
#define EPS 0.00000001
#define lowbit(x) (x&(-x))
using namespace std;
typedef long long ll; char a1[][] = {"UFS2.0","UFS2.1","eMMC5.1"};
char a2[][] = {"LPDDR3","LPDDR4"};
char a3[][] = {"Sparse","Normal"}; double r1[][] = {{,,},{,,}};
double r2[][] = {{,},{,}};
double r3[][] = {{,},{,}}; int main()
{
int T;
scanf("%d",&T);
while(T--)
{
int n;
char s1[],s2[],s3[];
double ans1 = , ans2 = ;
scanf("%d",&n);
for(int i=;i<n;i++)
{
scanf("%s%s%s",s1,s2,s3); for(int i=;i<;i++)
if(strcmp(s1,a1[i]) == )
{
ans1 += log(r1[][i]);
ans2 += log(r1[][i]);
break;
} for(int i=;i<;i++)
if(strcmp(s2,a2[i]) == )
{
ans1 += log(r2[][i]);
ans2 += log(r2[][i]);
break;
} for(int i=;i<;i++)
if(strcmp(s3,a3[i]) == )
{
ans1 += log(r3[][i]);
ans2 += log(r3[][i]);
break;
}
} if(abs(ans1 - ans2) <= EPS) printf("E\n");
else if(ans1 < ans2) printf("B\n");
else printf("A\n");
}
}
Time Limit: 2 Seconds Memory Limit: 65536 KB 17171771 is a sweet
17171771 is a sweet song in Jaurim's 5th album, "All You Need Is Love", released in October 2004.
What's the meaning of 17171771? If we rotate it by 180 degrees, it looks like "ILLILILI". If we add some blanks into it, it becomes "I LLILI LI". Doesn't it look like "I LUV U"? The meaning of 17171771 is "I LUV U". Anyway, it has nothing to do with our problem.
What we are concerned more about is that, 17171771 is a prime consisting only of digits 1 and 7 occurring with equal frequency. In this problem, a prime consisting only of two different digits occurring with equal frequency is called nice number. For example, 89, 71717117 and 23323333222223 are nice numbers.
Your task is to print all the nice numbers which are strictly less than 1018
Input
There is no input for this problem.
Output
Output all the nice number less than 1018 in increasing order. The output looks like the following:
13
17
19
...
17171771
...
AC代码:
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define INF 0x3f3f3f3f
#define lowbit(x) (x&(-x))
typedef long long ll;
using namespace std; vector <ll> vi;
set <ll> st; void dfs(int *a,int len)
{
do{
ll tp = ;
if(a[] == ) continue;
for(int i=;i<len;i++)
tp = tp * + a[i];
vi.push_back(tp);
}while(next_permutation(a, a + len));
} ll prime[] = {, , , , };
ll qmul(ll x, ll y, ll mod) // 乘法防止溢出, 如果p * p不爆ll的话可以直接乘; O(1)乘法或者转化成二进制加法
{
return (x * y - (ll)(x / (long double)mod * y + 1e-) * mod + mod) % mod;
}
ll qpow(ll a, ll n, ll mod)
{
ll ret = ;
while(n) {
if(n & ) ret = qmul(ret, a, mod);
a = qmul(a, a, mod);
n >>= ;
}
return ret;
}
bool Miller_Rabin(ll p)
{
if(p < ) return ;
if(p != && p % == ) return ;
ll s = p - ;
while(! (s & )) s >>= ;
for(int i = ; i < ; ++i)
{
if(p == prime[i]) return ;
ll t = s, m = qpow(prime[i], s, p);
while(t != p - && m != && m != p - ) {
m = qmul(m, m, p);
t <<= ;
}
if(m != p - && !(t & )) return ;
}
return ;
} int main()
{
int a[] = {};
for(int i=;i<=;i++)
for(int j=i+;j<=;j++)
for(int k=;k<=;k++)
{
for(int l=;l<k;l++)
{
a[l] = i;
a[l+k] = j;
}
dfs(a, k*);
}
for(int i=;i<vi.size();i++)
if(Miller_Rabin(vi[i]))
st.insert(vi[i]); int cnt = ;
for(set<ll>::iterator it = st.begin(); it != st.end(); it++)
{
printf("%lld\n",(*it));
cnt ++;
}
cout << cnt << endl;
}
2017CCPC秦皇岛的更多相关文章
- 2017CCPC秦皇岛G ZOJ 3987Numbers(大数+贪心)
Numbers Time Limit: 2 Seconds Memory Limit: 65536 KB DreamGrid has a nonnegative integer n . He ...
- 2017CCPC秦皇岛 H题Prime Set&&ZOJ3988
题意: 定义一种集合,只有两个数,两个数不同且加起来为素数.要从n个数里抽出数字组成该集合(数字也可以是1~n,这个好懵圈啊),要求你选择最多k个该种集合组成一个有最多元素的集合,求出元素的数量. 思 ...
- 2017CCPC秦皇岛 G题Numbers&&ZOJ3987【大数】
题意: 给出一个数n,现在要将它分为m个数,这m个数相加起来必须等于n,并且要使得这m个数的或值最小. 思路: 从二进制的角度分析,如果这m个数中有一个数某一位为1,那么最后或起来这一位肯定是为1的, ...
- 2017CCPC秦皇岛 A题Balloon Robot&&ZOJ3981【模拟】
题意: 一个机器人在长为M的圆形轨道上送气球,当机器人到达M号点的时候下一站会回到1号点,且全程不会停止运动.现在在长为M的轨道上有N个队伍,队伍会在某个时间做需要一个气球,机器人需要送过去.一共有P ...
- 2017CCPC秦皇岛 M题Safest Buildings&&ZOJ3993【复杂模拟】
题意: 给出两个半径R,r,R表示第一次的大圈半径,r表示第二次的小圈半径.第一次大圈的圆心位于(0,0),第二次小圈的圆心未知,但在大圈内,给你一个n,然后给出n个屋子的位置,问这些屋子中,第二次在 ...
- 2017CCPC秦皇岛 E题String of CCPC&&ZOJ3985【模拟】
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3985 题意: 给定一个字符串,由c和p组成,可以添加c或者p. 串中出现一 ...
- 2017CCPC秦皇岛 C题Crusaders Quest&&ZOJ3983【模拟+STL】
链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3983 题意: 给定9个血槽,有三种物品,每次可以把连续相同的物品抵消 ...
- 2017CCPC秦皇岛 L题One-Dimensional Maze&&ZOJ3992【模拟】
链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3992 题意: 走迷宫,一个一维字符串迷宫,由'L'.'R'组成,分别 ...
- ZOJ 3981 && 2017CCPC秦皇岛 A:Balloon Robot(思维题)
A - Balloon Robot Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%lld & %llu Sub ...
随机推荐
- struct timeval和gettimeofday
struct timeval和gettimeofday() struct timeval结构体在time.h中的定义为: struct timeval { time_t tv_sec; /* Seco ...
- Asp 日期格式化问题 沙比作者,我改过来。
Asp 日期格式化问题 投稿:mdxy-dxy 字体:[增加 减小] 类型:转载 时间:2009-06-14我要评论 asp做网站经常遇到日期格式处理问题,介绍一个有用的vbscript函数forma ...
- String,StringBuffer,StringBuild的区别
1.三者在执行速度方面的比较:StringBuilder > StringBuffer > String 2.String <(StringBuffer,StringBuild ...
- Python学习笔记(3)for循环和while循环
2019-02-25 (1)break语句:终止当前循环,跳出循环体. (2)continue语句:终止本轮循环并开始下一轮循环(在下一轮循环开始前,会先测试循环条件). (3)for循环 ① ran ...
- 做支付遇到的HttpClient大坑
前言 HTTPClient大家应该都很熟悉,一个很好的抓网页,刷投票或者刷浏览量的工具.但是还有一项非常重要的功能就是外部接口调用,比如说发起微信支付,支付宝退款接口调用等:最近我们在这个工具上栽了一 ...
- 【ACM-ICPC 2018 沈阳赛区网络预赛 K】Supreme Number
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 显然每个数字只可能是1,3,5,7 然后如果3,5,7这些数字出现两次以上.显然两个3||5||7都能被11整除. 然后1的话最多能 ...
- 关系数据库标准语言SQL
篇幅过长,恐惧者慎入!!!基础知识,大神请绕道!!! 本节要点: l SQL概述 l 学生-课程关系 l 数据定义 基本表的定义.删除与修改 索引的建立与删除 l 查询 单表查询 连接查询 嵌 ...
- 洛谷 P1124 文件压缩
P1124 文件压缩 题目背景 提高文件的压缩率一直是人们追求的目标.近几年有人提出了这样一种算法,它虽然只是单纯地对文件进行重排,本身并不压缩文件,但是经这种算法调整后的文件在大多数情况下都能获得比 ...
- WifiManager类具体解释
public class WifiManager extends Object java.lang.Object ↳ android.net.wifi.WifiManager 类概述 This ...
- 调用imagemagick做响应图片
设计出图后经常需要改下尺寸放在别的项目上使用,每次都是设计手工处理,其实图片服务可以做更多事情,比如借助强大的im,可以通过url控制图片尺寸 var childProcess = require(' ...