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 使用相同的 ...
随机推荐
- 前端之css(宽高)设置小技巧
一.css宽高自适应: 1.宽度自适应: 元素宽度设为100%(块状元素的默认宽度为100%) 注:应用在通栏效果中 2.高度自适应: height:auto;或者不设置高度 3.最小,最大高度,最小 ...
- Java类的静态块の二
在上一篇Java类的静态块の一中介绍到:类的静态块在类加载时候执行,执行早于构造函数,并且只执行一次. 但是在下面的例子中却发现JVM并不是把把所有的static模块都执行完成再执行其他(Java果然 ...
- 详解ASP.NET缓存机制
文中对ASP.NET的缓存机制进行了简述,ASP.NET中的缓存极大的简化了开发人员的使用,如果使用得当,程序性能会有客观的提升.缓存是在内存存储数据的一项技术,也是ASP.NET中提供的重要特性之一 ...
- Linux下环境搭建(三)——jmeter+ant配置
在linux环境下,使用jmeter做接口自动化,做好了前两步的准备工作后,怎能少了主角jmeter+ant了,今天就来说下jmeter+ant的配置方式. jmeter配置 jmeter下载地址:h ...
- ef导航属性
https://msdn.microsoft.com/en-us/data/jj574232.aspx 场景是 A表中有B,B表中又C.都是一堆多的关系.怎样Mapping是个问题啊. var ...
- MyEclipse中把java项目打包——含有第三方jar包【转】
也适用于eclipse导出jar. 在将项目打包为jar包时一直出现“ClassNotDefFound”错误,百度了很多解决办法都没有解决.最终找到一个很好的解决办法. 1.打包步骤 (1)右键单击j ...
- SQL 时间日期函数
1.获取当前日期GetDate getdate()函数以datetime数据类型的格式返回当前SQLServer服务器所在计算机的日期和时间.其语法格式为getdate().返回值舍入到最近的秒小数部 ...
- 允许Java App(applet)粘贴方法
修改安全策略文件: "java.policy" JRE6的路径在:"C:\Program Files (x86)\Java\jre6\lib\security" ...
- 分享一个WebGL开发的网站-用JavaScript + WebGL开发3D模型
这张图每位程序员应该都深有感触. 人民心目中的程序员是这样的:坐在电脑面前噼里啪啦敲着键盘,运键如飞. 现实中程序员是这样的:编码5分钟,调试两小时. 今天我要给大家分享一个用WebGL开发的网站,感 ...
- (2)JSTL的fmt国际化标签库
format标签库:做国际化格式化,分两类 : 国际化核心标签:<fmt:setLocale>.<fmt:bundle>.<fmt:setBundle>.<f ...