当前位置:网站首页>(lightoj - 1354) IP checking (Analog)
(lightoj - 1354) IP checking (Analog)
2022-07-06 16:23:00 【AC__ dream】
Topic link :IP Checking - LightOJ 1354 - Virtual Judge
The question : Here are two for you ip Address , One is decimal , The other is binary , Now ask you two ip Is the address the same
This is simpler , Is to examine a binary conversion , Every ip Addresses are represented by four integers , When reading in, we'd better use scanf formatted input , We just need to compare whether the four binary numbers and decimal numbers are equal in turn .
Here is the code :
#include<cstdio>
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
using namespace std;
int change(int x)// Will be binary x Convert to decimal
{
int ans=0;
for(int i=0;;i++)
{
if(x&1) ans+=1<<i;
x/=10;
if(!x) return ans;
}
}
int main()
{
int T;
cin>>T;
int a1,a2,a3,a4,b1,b2,b3,b4;
for(int _=1;_<=T;_++)
{
printf("Case %d: ",_);
scanf("%d.%d.%d.%d",&a1,&a2,&a3,&a4);
scanf("%d.%d.%d.%d",&b1,&b2,&b3,&b4);
if(a1!=change(b1)||a2!=change(b2)||a3!=change(b3)||a4!=change(b4)) puts("No");
else puts("Yes");
}
return 0;
}
边栏推荐
- Data storage in memory & loading into memory to make the program run
- Input can only input numbers, limited input
- F - birthday cake (Shandong race)
- Codeforces Round #802(Div. 2)A~D
- Ball Dropping
- Flask框架配置loguru日志库
- Study notes of Tutu - process
- Write web games in C language
- Problem - 1646C. Factorials and Powers of Two - Codeforces
- Oneforall installation and use
猜你喜欢
Kubernetes cluster deployment
Borg maze (bfs+ minimum spanning tree) (problem solving report)
“鬼鬼祟祟的”新小行星将在本周安全掠过地球:如何观看
Basic Q & A of introductory C language
读取和保存zarr文件
Codeforces Round #799 (Div. 4)A~H
QT style settings of qcobobox controls (rounded corners, drop-down boxes, up expansion, editable, internal layout, etc.)
Flask框架配置loguru日志库
QT模拟鼠标事件,实现点击双击移动拖拽等
Codeforces Round #802(Div. 2)A~D
随机推荐
Opencv learning log 28 -- detect the red cup cover
浏览器打印边距,默认/无边距,占满1页A4
QNetworkAccessManager实现ftp功能总结
QT模拟鼠标事件,实现点击双击移动拖拽等
Raspberry pie csi/usb camera uses mjpg to realize web camera monitoring
antd upload beforeUpload中禁止触发onchange
(POJ - 3579) median (two points)
Hdu-6025-prime sequence (girls' competition)
Maximum product (greedy)
Useeffect, triggered when function components are mounted and unloaded
Differential (one-dimensional, two-dimensional, three-dimensional) Blue Bridge Cup three body attack
QT realizes window topping, topping state switching, and multi window topping priority relationship
860. Lemonade change
QT实现窗口渐变消失QPropertyAnimation+进度条
socket通讯
window11 conda安装pytorch过程中遇到的一些问题
Codeforces Round #802(Div. 2)A~D
Candy delivery (Mathematics)
Effet d'utilisation, déclenché lorsque les composants de la fonction sont montés et déchargés
7-1 understand everything (20 points)