Codeforces Beta Round #57 (Div. 2), problem: (A) Ultra-Fast Mathematician editorial: http://codeforces.com/blog/entry/1342
Codeforces Beta Round #57 (Div. 2), problem: (A) Ultra-Fast Mathematician solution: http://ideone.com/3re7sc
#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> using namespace std; int main() { int c, d; char a[105], b[105]; string e=""; scanf("%s%s", a, b); for(int i=0; i<strlen(a); i++) { if(a[i]=='1') c=1; else c=0; if(b[i]=='1') d=1; else d=0; if(c^d) e+='1'; else e+='0'; } printf("%s", e.c_str()); //http://stackoverflow.com/a/6419751/2948746 return 0; }
for xor c++: http://en.wikipedia.org/wiki/Bitwise_operations_in_C & http://www.cplusplus.com/doc/boolean/
for c_str() c++: http://stackoverflow.com/a/6419751/2948746
No comments:
Post a Comment