热身赛

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. js判断当前移动设备平台

    //js判断当前移动设备平台 var isiOs = false; var isAndroid = false; var isWindowsPhone = false; if(/(iPhone|iPa ...

  2. 【vue】v-if和v-show的区别

    今天来捋一下vue中的v-if与v-show的区别 先来看一下vue官方文档对他们的解释 2.从实现方式来看: v-if是当依赖的值变为false时,直接让元素消失,html代码也会消失,相当于直接在 ...

  3. 兼容IE的两端对齐

    div+css布局实现2端对齐是我们网页排版中经常会使用到的,这篇文章将总结一下可以实现的方法: html结构 实现demo里面的div通过Css进行2端对齐. <div class=" ...

  4. linux 中配置假域名来测试

    1.linux中配置假域名 找到hosts文件进行编辑 命令:vim /etc/hosts 配置: #centos(本机IP)192.168.1.179 www.imooc.com(假域名,自己设置) ...

  5. C#常用 API函数大全

    常用Windows API1. API之网络函数WNetAddConnection 创建同一个网络资源的永久性连接WNetAddConnection2 创建同一个网络资源的连接WNetAddConne ...

  6. 小松之LINUX 驱动学习笔记(一)

    本篇主要是讲解驱动开发的基础知识以及一些环境配置方面的问题. 下面是一个hello world的简单的模块代码,很简单./*********************** 模块的简单例子* author ...

  7. 基于mybatis的CRUD

    u  基于Mybatis的CRUD u  掌握MyBatis的结果类型-resultMap和resultType u  掌握MyBatis的参数类型 u  掌握#和$两种语法 1      基于myb ...

  8. yii 表单小部件使用

    首先创建model层 因为要使用表单小部件 所以要加载相应的组件 这里需要的组件有 yii\widgets\ActiveForm 和 yii\helpers\Html 接下来在model定义的clas ...

  9. tomcat设置编码utf8

    1.       Java类: CharacterEncodingFilter  import javax.servlet.*; import java.io.IOException; public ...

  10. [using_microsoft_infopath_2010]Chapter8 使用InfoPath表单web部件

    本章概要: 1.配置web part 2.创建web part连接 3.创建表单参数 4.利用其它浏览器表单参数