TOJ 5021: Exchange Puzzle
5021: Exchange Puzzle 
Total Submit: 24 Accepted:4
Description
Given the expression (B+E+S+S+I+E)(G+O+E+S)(M+O+O), containing the seven variables B,E,S,I,G,O,M (the "O" is a variable, not a zero). For each variable, given a list of up to 500 integer values the variable can possibly take, you need to count the number of different ways that can assign values to the variables so the entire expression evaluates to a multiple of 7.
Note that the answer to this problem can be too large to fit into a 32-bit integer, so you probably want to use 64-bit integers.
Input
The first line of the input contains an integer N. The next N lines each contain a variable and a possible value for that variable. Each variable will appear in this list at least once and at most 500 times. No possible value will be listed more than once for the same variable. All possible values will be in the range −105 to 105.
Output
Print a single integer, giving the number of ways that you can assign values to variables so the expression above evaluates to a multiple of 7.
Sample Input
10
B 2
E 5
S 7
I 10
O 16
M 19
B 3
G 1
I 9
M 2
Sample Output
2
Hint
The two possible assignments are
(B,E,S,I,G,O,M)
= (2, 5, 7, 9, 1, 16, 19) -> 51,765
= (2, 5, 7, 9, 1, 16, 2 ) -> 34,510
Source
我感觉我的代码稳稳稳,因为时间限制,不可能枚举那么多数,只存在+的关系,所以先取模分下类
#include<stdio.h>
int S[],v[][];
int main(){
int n;S['B']=,S['E']=,S['S']=,S['I']=,S['G']=,S['O']=,S['M']=;
scanf("%d",&n);
for(int i=;i<n;i++){
getchar();
char c;int x;
scanf("%c%d",&c,&x);
v[S[c]][((x%)+)%]++;
}
__int64 cnt=;
for(int i=;i<;i++){__int64 B=v[][i];
for(int j=;j<;j++){int E=v[][j];
for(int k=;k<;k++){int S=v[][k];
for(int l=;l<;l++){int I=v[][l];
for(int m=;m<;m++){int G=v[][m];
for(int n=;n<;n++){int O=v[][n];
for(int o=;o<;o++){int M=v[][o];
if((i+*j+*k+l)*(m+n+j+k)*(o+*n)%==)
cnt+=B*E*S*I*G*O*M;}}}}}}}
printf("%I64d\n",cnt);
return ;}
TOJ 5021: Exchange Puzzle的更多相关文章
- POJ 2893 M × N Puzzle(树状数组求逆序对)
M × N Puzzle Time Limit: 4000MS Memory ...
- UESTC_Eight Puzzle 2015 UESTC Training for Search Algorithm & String<Problem F>
F - Eight Puzzle Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others) ...
- M × N Puzzle POJ - 2893(奇数码)
The Eight Puzzle, among other sliding-tile puzzles, is one of the famous problems in artificial inte ...
- 2015 UESTC 搜索专题F题 Eight Puzzle 爆搜
Eight Puzzle Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/contest/show/61 ...
- POJ 2983 M × N Puzzle
M × N Puzzle Time Limit: 4000MS Memory Limit: 131072K Total Submissions: 4860 Accepted: 1321 Des ...
- OpenCASCADE Data Exchange - 3D PDF
OpenCASCADE Data Exchange - 3D PDF eryar@163.com Abstract. Today most 3D engineering model data are ...
- Puzzle 面向服务/切面(AOP/IOC)开发框架 For .Net
Puzzle 面向服务/切面AOP开发框架 For .Net AOP主要实现的目的是针对业务处理过程中的切面进行提取,它所面对的是处理过程中的某个步骤或阶段,以获得逻辑过程中各部分之间低耦合性的隔离效 ...
- RabbitMQ学习系列(四): 几种Exchange 模式
上一篇,讲了RabbitMQ的具体用法,可以看看这篇文章:RabbitMQ学习系列(三): C# 如何使用 RabbitMQ.今天说些理论的东西,Exchange 的几种模式. AMQP协议中的核心思 ...
- [Exchange 2013]创建约会和会议
简介 会议和约会之间的重要区别是,会议有与会者,并且没有约会.约会和会议可以是单实例或属于重复序列,但与会者. 房间或资源中不包括约会,因为它们不需要发送一条消息.在内部,Exchange 使用相同的 ...
随机推荐
- Bootstrap基础知识学习
Bootstrap中文网 http://www.bootcss.com/ Bootstrap菜鸟教程 http://www.runoob.com/bootstrap/bootstrap-tutoria ...
- No input file specified的解决方法
(一)IIS Noinput file specified 方法一:改PHP.ini中的doc_root行,打开ini文件注释掉此行,然后重启IIS 方法二:请修改php.ini找到; cgi.for ...
- C# 一维数组 冒泡排序
假设有个三个杯子 一个杯子中有一个紫色的乒乓球 一个没有 一个有红色乒乓球 杯子不能动 怎么把紫色和红色的调换呢 主要是先把紫色的放到空的杯子 在把红的放到紫色原来的杯子 再把 ...
- C# 语句 分支语句
语句是指程序命令,按照顺序执行.可以分为 顺序语句 分支语句 循环语句 之前学习的内容都是按照顺序程序执行的,称之为顺序语句. 今天学的的内容是分支语句. 语句可以嵌套,可以是以分号结尾的单行 ...
- 测试ReplicaSets读写分离和故障转移
读写分离实现步骤: 从库能够进行查询就更好了,这样可以分担主库的大量的查询请求. 1) 先向主库中插入一条测试数据 rs1:PRIMARY> db.c1.insert({age:30});db. ...
- NSString+TimeCategory
NSString+TimeCategory.h //------------------------------------------------ #import <foundation fo ...
- Linux文件操作函数
creat() 函数 close() 函数 read() 函数 read 函数实际读到的字节数少于要求读的字节数时: 读普通文件,在读到要求字节数之前就到达文件尾: 当从终端设备读,通常一次最多读一行 ...
- Python-DB接口规范
threadsafety 线程安全级别.threadsafety 这是一个整数, 取值范围如下: 0:不支持线程安全, 多个线程不能共享此模块 1:初级线程安全支持: 线程可以共享模块, 但不能共享连 ...
- 关于windows server 2003 IE 不能访问 https问题
https://xx.wosign.com/FAQ/Windows2003_server_sha256_support_problem.html 补丁地址: https://xx.wosign.com ...
- react入门(上)
1. ReactJS是什么? 1). Facebook开源的一个js库 2). 一个用于动态构建用户界面的js库2. React的特点 * Declarative(声明式编码) * Component ...