2016 Al-Baath University Training Camp Contest-1 C
Description
Rami went back from school and he had an easy homework about bitwise operations (and,or,..) The homework was like this : You have an equation : " A | B = C " ( this bar '|' means OR ) you are given the value of A and B , you need to find the value of C ?? as we said before this is an easy question for Rami to solve ,but he wonderd if the equation was like this: " A | C = B " and he is given the value of A and B , how many value of C exists ?? Rami wants your help in this hard question ... He will help you as much as he can ,so he will convert the two decimal numbers(A and B) to binary representaion ( like this: if A=6 –> A=110 ) and this what he knows about OR operation and might be helpfull with your task :
The input consists of several test cases. The first line of the input contains a single integer T, the number of the test cases. each test case consists of 3 lines : the 1st line is the length of the binary representaion of the 2 numbers.1<=n<=100 the 2nd line is the number A in base 2 .(a string consits of 0s and 1s only ) the 3rd line is the number B in base 2 .(a string consits of 0s and 1s only )
for each test case,you need to print the number of possible values of C that make the eqaution correct in a seperate line .(read page 2 carefully)
3
2
10
11
3
110
110
4
1110
1011
2
4
IMPOSSIBLE
as the answer may be very very large , you should print the answer mod 1000000007. there might be no answer for the equation also , in this case you should print "IMPOSSIBLE" (without qoutes).
题意:A|C==B,问C符合情况的有多少种
解法:1|x=1,x有两种选法,1|x=0不符合规定,输出impossible,其他是一种情况
那么只需要判断1|x=1就行
#include <iostream>
#define ll long long
using namespace std;
int main(){
ll T,mod=1000000007,ans=0;
string s1,s2;
cin>>T;
while(T--){
int n;
cin>>n;
cin>>s1>>s2;
ans=1;
for(int i=0;i<n;i++){
if(s1[i]=='1'){
if(s2[i]=='1') ans*=2;
else{
ans=-1;
break;
}
}
ans%=mod;
}
if(ans==-1) cout<<"IMPOSSIBLE"<<endl;
else cout<<ans<<endl;
}
}
2016 Al-Baath University Training Camp Contest-1 C的更多相关文章
- 2016 Al-Baath University Training Camp Contest-1
2016 Al-Baath University Training Camp Contest-1 A题:http://codeforces.com/gym/101028/problem/A 题意:比赛 ...
- 2014-2015 Petrozavodsk Winter Training Camp, Contest.58 (Makoto rng_58 Soejima contest)
2014-2015 Petrozavodsk Winter Training Camp, Contest.58 (Makoto rng_58 Soejima contest) Problem A. M ...
- 2016 Al-Baath University Training Camp Contest-1 E
Description ACM-SCPC-2017 is approaching every university is trying to do its best in order to be th ...
- 2016 Al-Baath University Training Camp Contest-1 B
Description A group of junior programmers are attending an advanced programming camp, where they lea ...
- 2016 Al-Baath University Training Camp Contest-1 A
Description Tourist likes competitive programming and he has his own Codeforces account. He particip ...
- 2016 Al-Baath University Training Camp Contest-1 J
Description X is fighting beasts in the forest, in order to have a better chance to survive he's gon ...
- 2016 Al-Baath University Training Camp Contest-1 I
Description It is raining again! Youssef really forgot that there is a chance of rain in March, so h ...
- 2016 Al-Baath University Training Camp Contest-1 H
Description You've possibly heard about 'The Endless River'. However, if not, we are introducing it ...
- 2016 Al-Baath University Training Camp Contest-1 G
Description The forces of evil are about to disappear since our hero is now on top on the tower of e ...
- 2016 Al-Baath University Training Camp Contest-1 F
Description Zaid has two words, a of length between 4 and 1000 and b of length 4 exactly. The word a ...
随机推荐
- [原创]java WEB学习笔记66:Struts2 学习之路--Struts的CRUD操作( 查看 / 删除/ 添加) 使用 paramsPrepareParamsStack 重构代码 ,PrepareInterceptor拦截器,paramsPrepareParamsStack 拦截器栈
本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...
- 在Visual Studio 2013/2015上使用C#开发Android/IOS安装包和操作步骤
Xamarin 配置手册和离线包下载 http://pan.baidu.com/s/1eQ3qw8a 具体操作: 安装前提条件 1. 安装Visual Studio 2013,安装过程省略,我这里安装 ...
- PAT乙级 1005. 继续(3n+1)猜想 (25)
1005. 继续(3n+1)猜想 (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 卡拉兹(Callatz ...
- js 字符串哈希函数
废话不多说直接上代码 /** * 获取字符串的哈希值 * @param {String} str * @param {Boolean} caseSensitive * @return {Number} ...
- linux中查看硬件温度的命令
用到的命令是: sensors 这个命令来自一个叫 lm_sensors 的包. 执行 sensors-detect 可以以询问的方式做一些配置(可以选择检测哪些硬件的温度).
- yii2语言设置
1.父配置文件在yii2/base/Application中的$language="en-US", 修改项目的语言可以修改项目的配置文件main.php中加'language'=& ...
- install chrome in elementary os
Elementary OS Freya 0.3.2 was officially out for public. As previous release, it comes pre-installed ...
- NOIP201401珠心算测验
珠心算测验 问题描述] 珠心算是一种通过在脑中模拟算盘变化来完成快速运算的一种计算技术.珠心算训练,既能够开发智力,又能够为日常生活带来很多便利,因而在很多学校得到普及. 某学校的珠心算老师采用 ...
- Elasticsearch--配置文件
config目录下有2个配置文件:es的配置文件:elasticsearch.yml日志配置文件:logging.yml,更多内容请参考:ELK教程 cluster.name: elasticsear ...
- Oracle 行迁移和行链接
一.行迁移 1.1.行迁移概念 当一个行上的更新操作(原来的数据存在且没有减少)导致当前的数据不能在容纳在当前块,我们需要进行行迁移.一个行迁移意味着整行数据将会移动,仅仅保留的是一个转移地址.因此整 ...