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 ...
随机推荐
- 计蒜客 宝藏 (状压DP)
链接 : Here! 思路 : 状压DP. 开始想直接爆搜, T掉了, 然后就采用了状压DP的方法来做. 定义$f[S]$为集合$S$的最小代价, $dis[i]$则记录第$i$个点的"深度 ...
- Ubuntu18.04 安装 oh-my-zsh
目录 Ubuntu18.04 安装 oh-my-zsh 目录 安装zsh 安装curl 安装oh-my-zsh 使用zsh替换bash 修改终端主题和配色 修改终端配置 隐藏用户和主机名 效果图 Ub ...
- C#封装成DLL,并在C#中调用
一.C#封装成DLL 1.在VS中创建项目选择类库,命名 myDll 2.建立好项目后自动生成的代码如下: 代码修改如下,添加自己要封装的C#代码,注意修饰符必须为public using Syste ...
- 【Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) A】 Doggo Recoloring
[链接] 我是链接,点我呀:) [题意] 你可以把出现次数大于1的颜色换成其他颜色. 问你最后能不能全都变成同一种颜色 [题解] 判断一下有没有出现次数大于1的就好. 有的话.显然可以一直用它变颜色. ...
- Java的五大原则
五个基本原则: 单一职责原则(Single-Resposibility Principle):一个类,最好只做一件事,只有一个引起它的变化.单一职责原则可以看做是低耦合.高内聚在面向对象原则上的引申, ...
- [using_microsoft_infopath_2010]Chapter12 管理监视InfoPath表单服务
本章概要: 1.在SharePoint中心控制台管理InfoPath设置 2.分析监视浏览器表单开考虑潜在性能问题 3.最小化回发数据
- HorizontalDragLayout-模仿QQclient的Item滑动删除
首先感谢http://blog.csdn.net/lmj623565791/article/details/46858663hongyang的文章.之前看过ViewDragHelper类也读过一些de ...
- [Angular] ngx-formly (AKA angular-formly for Angular latest version)
In our dynamic forms lessons we obviously didn’t account for all the various edge cases you might co ...
- SVN文件恢复
SVN删除文件 一.本地删除 SVN删除文件里的本地删除,指的是在clientdelete了一个文件,但还没有commit.使用revert来撤销删除. 二.server删除 1.通过本地删除后提交s ...
- IOS-2-C语言和Objective-C语言衔接学习资料
前言:在IOS学习中.通常会先学习一周的C语言,两周的Objective-C语言,这是今后开发的最基础最重要的部分,以下给大家分享一下培训课上的精简资料: C语言和Objective-C语言衔接学习资 ...