題目連結 UVa 10929
先換成二進位 再算出二進位有幾個1
#include<iostream>
using namespace std;
int main()
{
int n;
while(cin>>n and n!=0)
{
int bin[31]={0},cnt=0,i=-1,j;
while(n!=0)
{
i++;
if(n%2==0)
{
bin[i]=0;
n/=2;
}
else
{
bin[i]=1;
n-=1;
n/=2;
}
}
cout<<"The parity of ";
for(j=i;j>=0;j--)
{
cnt+=bin[j];
cout<<bin[j];
}
cout<<" is "<<cnt<<" (mod 2)."<<endl;
}
}
UVA
回目錄 學習筆記
CPE 一星 UVa 00100 || The 3n + 1 problem UVa 00272 || TEX Quotes UVa 00299 || Train Swapping UVa 00948 || Fibonaccimal Base UVa 10010 || Bangla Numbers UVa 10019 || Funny Encryption Method UVa 10038 || Jolly jumper UVa 10041 || Vito's Family
Oct 1, 2021題目連結 UVa 12019 中文簡述 給你一個日期,算出在2011是星期幾。 [think] 題目有提到說2011/4/4是星期一 可以得知 2011的第93天是星期一
Sep 28, 2021DEC BIN 0 0000 1 0001 2
Sep 7, 2021題目連結 UVa 10252 中文簡述 輸入兩個字串,輸出兩個字串共同的英文字母 [think] 用兩個陣列分別記錄字母的分布 最後用迴圈去比對有哪些字母重疊 solution:
Aug 23, 2021or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up