热身赛

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. linux下查看mysql版本的四种方法

    Linux查看MySQL版本的四种方法 1 在终端下执行 mysql -V 2 在help中查找 mysql --help |grep Distrib 3 在mysql 里查看 select vers ...

  2. 了解http协议

    http:超文本传输协议 https:安全超文本传输协议 FTP:文件传输协议 TCP:网络控制协议 IP:互联网协议 UDP:用户数据协议 https协议特点-------------------- ...

  3. flask_sqlalchemy和sqlalchemy联系区别及其使用方式

    ### 使用SQLAlchemy去连接数据库: 1.使用SQLALchemy去连接数据库,需要使用一些配置信息,然后将他们组合成满足条件的字符串:HOSTNAME = '127.0.0.1'PORT ...

  4. IIS部署ASP.NET网站后提示只有在配置文件或 Page 指令中将 enableSessionState 设置为 true 时,才能使用会话状态...

    今天,在IIS上部署网站后,出现了下面错误: 只有在配置文件或 Page 指令中将 enableSessionState 设置为 true 时,才能使用会话状态.还请确保在应用程序配置的 <sy ...

  5. [Linux]第四部分-Linux用户管理

    登陆过程:1.从etc/passwd中查找账号,没有则退出,然后在etc/shadow中读出uid与密码表passwd中内容格式 用户名:密码:UID:GID:用户信息说明:家目录:用户所用Shell ...

  6. 写一个函数,输入int型,返回整数逆序后的字符串

    刚刚看到一个面试题:写一个函数,输入int型,返回整数逆序后的字符串.如:输入123,返回"321". 要求必须用递归,不能用全局变量,输入必须是一个參数.必须返回字符串.&quo ...

  7. 【1】按照Django官网,编写一个web app 创建project/配置数据库

    1. Creating a project From the command line, cd into a directory where you'd like to store your code ...

  8. awesome-free-software

    Free software is distributed under terms that allow users to run the program for any purpose, study ...

  9. C语言的长处和缺点

     C语言的长处和缺点 C语言的长处: 1.面向过程的语言C语言是面向过程的语言,在这里用户创建过程或函数来运行他们的任务. 面向过程的语言是非常easy学.因为它遵循的算法来运行你的语句.要使用面 ...

  10. Swift3.0 闭包整理

    语法表达式 一般形式:{             (parameters) -> returnType in              statements            } 这里的参数 ...