首页
DreamJudge
院校信息
专业题库
模拟考试
机试真题
上岸课程
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
阿灿
2025年3月18日 18:56
二进制数 题解:log一下就好了
P1380
回复 0
|
赞 1
|
浏览 117
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; // 计算需要的二进制位数 int bits = n == 0 ? 1 : static_cast<int>(log2(n)) + 1; cout << bitset<32>(n).to_string().substr(32 - bits) << endl; return 0; } ...
zxjrheaven
2025年3月9日 15:49
二进制数 题解:暴力至高
P1380
回复 0
|
赞 7
|
浏览 245
#include <bits/stdc++.h> using namespace std; int num[32]={0}; int main() { unsigned int n; while(cin>>n) { int a=n; int j=-1;  ...
jaygee_
2025年3月6日 23:37
二进制数 题解:
P1380
回复 0
|
赞 3
|
浏览 170
使用string库函数 #include<bits/stdc++.h> using namespace std; int a[105]; int main() { int n; string s; while(cin >> n) { int cnt = 0; if(n == 0) { cout << '0' << endl; continue; } while(n > 0) { int num = n % 2; a[cnt ++] = num; ...
chenxx
2025年2月26日 18:58
二进制数 题解:
P1380
回复 0
|
赞 11
|
浏览 308
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; string ans; while(n){ ans += to_string(n%2); ...
ccccccyes
2024年8月26日 14:14
二进制数 题解:
P1380
回复 0
|
赞 15
|
浏览 675
//一个正整数转化成二进制 //去掉前面的0,但不是所有的0 //多轮输入 #include <iostream> #include <vector> using namespace std; int main(){ unsigned int n; vector<int> bi; int num; while(cin>>n){ while(n!=0){ num = n%2; bi.push_back(num); n /= 2; } } for(int i = b...
myming
2024年7月20日 20:32
二进制数 题解:
P1380
回复 0
|
赞 2
|
浏览 508
#include<bits/stdc++.h> using namespace std; void f(unsigned int x){ char y[1024] = {0}; int i = 0; while(x){ y[i++] = x % 2 + '0'; &...
青春渲染童年
2024年5月29日 15:56
二进制数 题解:<vector>容器解法
P1380
回复 0
|
赞 3
|
浏览 698
思想:采用模2取余法,倒序读取数字,即为十进制转化过后的二进制 #include<iostream> #include<vector> //vector的头文件 using namespace std; int main() { vector<int> n; ...
Candour
2024年4月24日 00:40
二进制数 (C++ 位运算)题解:
P1380
回复 0
|
赞 2
|
浏览 529
#include <bits/stdc++.h> using namespace std; int x; string res; int main() { cin >> x; while(x) { res.push_back((x & 1) + '0'); x >>= 1; } reverse(res.begin(), res.end()); cout << res; return 0; }
FCC
2024年3月15日 20:38
二进制数 题解:十进制转二进制(除留余数法)+vector<int>反
P1380
回复 0
|
赞 2
|
浏览 718
#include <bits/stdc++.h> using namespace std; int main(){ unsigned int n; cin >> n; int x; vector<int> arr; //十进制转二进制(除留余数法) while( n > 0 ){ x = n % 2; //注意是对2取模,因为转换成二进制 n /= 2; //注意是除2,因为转换成二进制 arr.push_back( x ); //非栈结构,相当于数组,故输出时反向输出 }...
光明守护神
2024年3月14日 21:24
二进制数 题解:C++
P1380
回复 0
|
赞 0
|
浏览 535
#include <iostream> #include <vector> using namespace std; int main() { auto n = 100000000; while (cin >> n) { vector<int> r(0); ...
1
2
3
题目
二进制数
题解数量
21
发布题解
在线答疑
热门题解
1
二进制数 题解:
2
二进制数 题解:
3
二进制数 题解:递归解决
4
二进制数 题解:暴力至高
5
二进制数 题解:
6
二进制数 题解:<vector>容器解法
7
二进制数 题解:C语言 两种方法 第一种itoa 第二种 栈
8
常规进制转换
9
思路比较直
10
c 二进制数