日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Refrain

發(fā)布時(shí)間:2023/12/8 编程问答 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Refrain 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

貪心...我都好奇自己當(dāng)時(shí)沒事干怎么就學(xué)了貪心...

當(dāng)然盡管這樣23道題我也沒寫完...

正如gg所說:我們要不厭其煩地寫題解。(當(dāng)然不存在的

1455:An Easy Problem

As we known, data stored in the computers is in binary form. The problem we discuss now is about the positive integers and its binary form.

Given a positive integer I, you task is to find out an integer J, which is the minimum integer greater than I, and the number of '1's in whose binary form is the same as that in the binary form of I.

For example, if "78" is given, we can write out its binary form, "1001110". This binary form has 4 '1's. The minimum integer, which is greater than "1001110" and also contains 4 '1's, is "1010011", i.e. "83", so you should output "83".
輸入One integer per line, which is I (1 <= I <= 1000000).

A line containing a number "0" terminates input, and this line need not be processed.
輸出One integer per line, which is J.
其實(shí)這題就是把一個(gè)數(shù)轉(zhuǎn)換為二進(jìn)制,1的數(shù)量要求一樣,要得到比給定數(shù)大的最小的數(shù)。
所以只要統(tǒng)計(jì)出有多少個(gè)一就好了。
不想解釋別的了qwqqqqq
#include<iostream> #include<cstdio> #include<algorithm> using namespace std; int gcd(int n) {int flag=0;while(n){if(n%2){flag++;}n/=2;}return flag; } int main() {int n;while(cin>>n){if(!n)break;int t=gcd(n);for(int i=n+1; ;i++){if(gcd(i)==t){cout<<i<<endl;break;}}}return 0; }

我們稱之為路的,無非是躊躇。

轉(zhuǎn)載于:https://www.cnblogs.com/Grigory/p/10159642.html

總結(jié)

以上是生活随笔為你收集整理的Refrain的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。