当前位置:网站首页>(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;
}
边栏推荐
- VMware Tools和open-vm-tools的安装与使用:解决虚拟机不全屏和无法传输文件的问题
- 日期加1天
- Flag framework configures loguru logstore
- 去掉input聚焦时的边框
- 628. Maximum product of three numbers
- HDU - 6024 building shops (girls' competition)
- Useeffect, triggered when function components are mounted and unloaded
- Advancedinstaller installation package custom action open file
- Kubernetes cluster deployment
- B - Code Party (girls' competition)
猜你喜欢
(POJ - 3685) matrix (two sets and two parts)
Frida hook so layer, protobuf data analysis
QT实现圆角窗口
pytorch提取骨架(可微)
Problem - 922D、Robot Vacuum Cleaner - Codeforces
Advancedinstaller installation package custom action open file
Kubernetes cluster deployment
Sword finger offer II 019 Delete at most one character to get a palindrome
Quick to typescript Guide
antd upload beforeUpload中禁止触发onchange
随机推荐
去掉input聚焦时的边框
Codeforces Round #799 (Div. 4)A~H
Problem - 1646C. Factorials and Powers of Two - Codeforces
It is forbidden to trigger onchange in antd upload beforeupload
Acwing: Game 58 of the week
QT按钮点击切换QLineEdit焦点(含代码)
AcWing——第55场周赛
Interesting drink
pytorch提取骨架(可微)
Specify the format time, and fill in zero before the month and days
Find 3-friendly Integers
605. Planting flowers
Flag framework configures loguru logstore
Acwing - game 55 of the week
860. Lemonade change
Codeforces Round #802(Div. 2)A~D
(POJ - 3258) River hopper (two points)
JS call camera
Opencv learning log 27 -- chip positioning
MariaDB的安装与配置