#UVa:10469-To Carry or not to Carry

灆洢 2012-11-29 07:58:47

將加運算換成XOR運算即可得解。

C++(0.008)

/*******************************************************/
/* UVa 10469 To Carry or not to Carry                  */
/* Author: Maplewing [at] knightzone.studio            */
/* Version: 2012/11/29                                 */
/*******************************************************/
#include <iostream>
#include <cstdio>
using namespace std;

int main(){
  unsigned int a, b;
  while( scanf( "%u%u", &a, &b ) != EOF ){
    printf( "%u\n", a^b );
  }
  return 0;
}

發表迴響

這個網站採用 Akismet 服務減少垃圾留言。進一步瞭解 Akismet 如何處理網站訪客的留言資料