当前位置:网站首页>(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;
}
边栏推荐
- Read and save zarr files
- Hdu-6025-prime sequence (girls' competition)
- 807. Maintain the urban skyline
- Specify the format time, and fill in zero before the month and days
- Opencv learning log 26 -- detect circular holes and mark them
- Raspberry pie csi/usb camera uses mjpg to realize web camera monitoring
- B - Code Party (girls' competition)
- Quick to typescript Guide
- Analysis of protobuf format of real-time barrage and historical barrage at station B
- (POJ - 2739) sum of constructive prime numbers (ruler or two points)
猜你喜欢
QT realizes window topping, topping state switching, and multi window topping priority relationship
1323. Maximum number of 6 and 9
C language learning notes
Candy delivery (Mathematics)
读取和保存zarr文件
The "sneaky" new asteroid will pass the earth safely this week: how to watch it
快速转 TypeScript 指南
Codeforces Round #802(Div. 2)A~D
Click QT button to switch qlineedit focus (including code)
Browser print margin, default / borderless, full 1 page A4
随机推荐
1013. Divide the array into three parts equal to and
Opencv learning log 28 -- detect the red cup cover
Kubernetes集群部署
Openwrt build Hello ipk
Browser print margin, default / borderless, full 1 page A4
Installation and configuration of MariaDB
QT style settings of qcobobox controls (rounded corners, drop-down boxes, up expansion, editable, internal layout, etc.)
Codeforces Round #802(Div. 2)A~D
TCP's three handshakes and four waves
1689. Ten - the minimum number of binary numbers
1605. Sum the feasible matrix for a given row and column
Advancedinstaller installation package custom action open file
分享一个在树莓派运行dash应用的实例。
Luogu P1102 A-B number pair (dichotomy, map, double pointer)
JS call camera
MariaDB的安装与配置
875. Leetcode, a banana lover
Install Jupiter notebook under Anaconda
树莓派4B安装opencv3.4.0
Read and save zarr files