热身赛

B题 Smartphone: 大整数相乘

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 


eMMC5.1 LPDDR4 Sparse 

UFS2.1 LPDDR3 Sparse 
UFS2.0 LPDDR4 Normal 

UFS2.1 LPDDR3 Sparse 
eMMC5.1 LPDDR4 Normal 
UFS2.0 LPDDR4 Normal 
Sample Output 


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");
}
}
 
D题 17171771:DFS + Miller_Rabin

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秦皇岛的更多相关文章

  1. 2017CCPC秦皇岛G ZOJ 3987Numbers(大数+贪心)

    Numbers Time Limit: 2 Seconds      Memory Limit: 65536 KB DreamGrid has a nonnegative integer n . He ...

  2. 2017CCPC秦皇岛 H题Prime Set&&ZOJ3988

    题意: 定义一种集合,只有两个数,两个数不同且加起来为素数.要从n个数里抽出数字组成该集合(数字也可以是1~n,这个好懵圈啊),要求你选择最多k个该种集合组成一个有最多元素的集合,求出元素的数量. 思 ...

  3. 2017CCPC秦皇岛 G题Numbers&&ZOJ3987【大数】

    题意: 给出一个数n,现在要将它分为m个数,这m个数相加起来必须等于n,并且要使得这m个数的或值最小. 思路: 从二进制的角度分析,如果这m个数中有一个数某一位为1,那么最后或起来这一位肯定是为1的, ...

  4. 2017CCPC秦皇岛 A题Balloon Robot&&ZOJ3981【模拟】

    题意: 一个机器人在长为M的圆形轨道上送气球,当机器人到达M号点的时候下一站会回到1号点,且全程不会停止运动.现在在长为M的轨道上有N个队伍,队伍会在某个时间做需要一个气球,机器人需要送过去.一共有P ...

  5. 2017CCPC秦皇岛 M题Safest Buildings&&ZOJ3993【复杂模拟】

    题意: 给出两个半径R,r,R表示第一次的大圈半径,r表示第二次的小圈半径.第一次大圈的圆心位于(0,0),第二次小圈的圆心未知,但在大圈内,给你一个n,然后给出n个屋子的位置,问这些屋子中,第二次在 ...

  6. 2017CCPC秦皇岛 E题String of CCPC&&ZOJ3985【模拟】

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3985 题意: 给定一个字符串,由c和p组成,可以添加c或者p. 串中出现一 ...

  7. 2017CCPC秦皇岛 C题Crusaders Quest&&ZOJ3983【模拟+STL】

    链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3983 题意: 给定9个血槽,有三种物品,每次可以把连续相同的物品抵消 ...

  8. 2017CCPC秦皇岛 L题One-Dimensional Maze&&ZOJ3992【模拟】

    链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3992 题意: 走迷宫,一个一维字符串迷宫,由'L'.'R'组成,分别 ...

  9. ZOJ 3981 && 2017CCPC秦皇岛 A:Balloon Robot(思维题)

    A - Balloon Robot Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Sub ...

随机推荐

  1. Quoit Design (HDU 1007)平面的最近点对

    题目大意:给定平面上的 n 个点,求距离最近的两个点的距离的一半. n <= 10^5.   晕乎乎的度过了一上午... 总之来学习下分治吧233 分治就是把大问题拆成小问题,然后根据对小问题处 ...

  2. 实验二:编写输出"Hello World!"

    1.首先打开eclipse这个软件,新建Java项目,执行“文件→ 新建→Java项目 ”菜单命令,打开新建Java对话框,在项目名的编辑框中输入项目名编写输出"Hello World!”, ...

  3. Linux(CentOS 6.4)系统中安装mplayer

    整了一个上午终于把mplayer安装上了,我的系统是centos 6.4,真是不容易啊! 一.准备工作 需要的安装包及下载地址:1.mplayer源代码包(MPlayer-1.0rc4.tar.bz2 ...

  4. vue使用SockJS实现webSocket通信

    以前使用websocket都是使用 window.webSocket = new WebSocket('ws://' + config.webSocketUrl + '/webData/websock ...

  5. Vue -- element-ui el-table 的合计在第一行显示并可点击

    使用element-ui el-table 中有这样一个需求,需要将合计放在表格内容的第一行,并且点击合计可跳转到其它页面! 框架中提供了合计的属性方法,这样可以进行数值求和及自定义求和,但是,合计那 ...

  6. position:fixed div如何居中

    div{position:fixed;margin:auto;left:0; right:0; top:0; bottom:0;width:200px; height:150px;}

  7. switch 的穿透, 以及穿透利用

    switch 穿透测试: outputs: 添加break 阻止switch穿透: outputs: 利用switch的穿透功能:

  8. 使用jekyll配置一个自己的blog

    使用coding.net上提供的pages服务来配置一个自己的站点 提示:下载这些软件,最好能FQ,有些链接是国外的,淘宝的ruby镜像已经不提供服务了 1. 安装Ruby 2. 安装Rubygems ...

  9. 洛谷 P1124 文件压缩

    P1124 文件压缩 题目背景 提高文件的压缩率一直是人们追求的目标.近几年有人提出了这样一种算法,它虽然只是单纯地对文件进行重排,本身并不压缩文件,但是经这种算法调整后的文件在大多数情况下都能获得比 ...

  10. POJ 2189

    P是端点,牛在区域中啊... #include <iostream> #include <cstdio> #include <cstring> #include & ...