当前位置:网站首页>PTA 1037 change at Hogwarts
PTA 1037 change at Hogwarts
2022-07-19 09:53:00 【Deng sb's father】
1037 Change at Hogwarts
#include <iostream>
using namespace std;
int main()
{
int P[3], A[3];
scanf("%d.%d.%d %d.%d.%d", &P[0], &P[1], &P[2], &A[0], &A[1], &A[2]);
int R[3];
for (int i = 0; i < 3; i++)
R[i] = A[i] - P[i];
while (!(R[2] >= 0 && R[2] < 29))
{
if (R[2] >= 29)
{
R[2] -= 29;
R[1]++;
}
else if (R[2] < 0)
{
R[2] += 29;
R[1]--;
}
}
while (!(R[1] >= 0 && R[1] < 17))
{
if (R[1] >= 17)
{
R[1] -= 17;
R[0]++;
}
else if (R[1] < 0)
{
R[1] += 17;
R[0]--;
}
}
if (R[0] < 0)
{
R[0]++;
R[1] -= 17;
R[1]++;
R[2] -= 29;
}
if (R[0] < 0 || R[1] < 0 || R[2] < 0)
printf("-%d.%d.%d", abs(R[0]), abs(R[1]), abs(R[2]));
else
printf("%d.%d.%d", R[0], R[1], R[2]);
}
Not perfect AC The answer , The reason may be the data range problem
#include <iostream>
using namespace std;
int main()
{
//17*29 Nate (Knut) = 17* Sickles (Sickle) = Garonne (Galleon)
long long int P1, P2, P3, A1, A2, A3; // Galleon.Sickle.Knut
scanf("%lld.%lld.%lld %lld.%lld.%lld", &P1, &P2, &P3, &A1, &A2, &A3);
P3 = P1 * 17 * 29 + P2 * 29 + P3;
A3 = A1 * 17 * 29 + A2 * 29 + A3;
long long int difference = A3 - P3;
bool flag;
if (difference > 0)
flag = true;
else
flag = false;
difference = abs(difference);
long long int D1, D2, D3;
D3 = difference % 29;
D2 = difference / 29;
D1 = D2 / 17;
D2 = D2 % 17;
if (!flag)
cout << "-";
printf("%lld.%lld.%lld", D1, D2, D3);
}
边栏推荐
- Chapter 12 list of STL
- 第一部分—C语言基础篇_3. 运算符与表达式
- [C language] summary of function knowledge points
- What is the product power of lantu dreamer?
- Componentized advanced -- slot
- v-mode
- 华为无线设备配置静态负载均衡
- [fishing artifact] UI library second low code tool - form part (II) sub control
- 【C语言】函数知识点总结
- Mysqldump full recovery to another new instance, and then perform flush privileges analysis
猜你喜欢

Chapter 4 - first order multi-agent system consistency - > switching topology system consistency

Componentized advanced -- slot

node+express搭建服务器环境

【C语言】自定义类型初阶知识点
![[C language] void type and void* pointer type](/img/4c/3643d850bfcb57db93496ec9bba06e.png)
[C language] void type and void* pointer type

Add - before the command in makefile to ignore the error caused by the command and continue to execute the next command

FAW Toyota Asia lion's first product refresh

【ACWing】947. 文本编辑器

565. 数组嵌套 / 剑指 Offer II 001. 整数除法
[email protected](Fe)复合纳米材料"/>金属有机骨架材料/聚合物复合材料ZIF-8/P(TDA-co-HDA)|氧化锌[email protected](Fe)复合纳米材料
随机推荐
Chapter 4 - first order multi-agent system consistency - > continuous time system consistency with time delay [program code]
一汽丰田亚洲狮首次产品焕新
18、shell脚本编程(1)
齐岳供应负载亚甲基蓝的CuMOF纳米晶|原位生长在泡沫镍上FeMOF纳米片|氧化物纳米线/ZIF系MOFs糖葫芦状复合材料
数组模拟队列
第一部分—C语言基础篇_2. 数据类型
Mux256to1v,Hadd,Fadd
How to correctly execute jedis unit test
氮杂环分子改性UiO-66-NH2|聚乙烯亚胺改性UiO-66-NH2|[email protected]@ZIF67纳米材料
The inflection point of eth may be just around the corner, which is how to
Chapter IX deque of STL
第4章-一阶多智体系统一致性 -> 切换拓扑系统一致性
Part I - Fundamentals of C language_ 2. Data type
Part I - Fundamentals of C language_ 6. Function
[C language] data type and meaning
关于基础模块中的依赖由微服务中的子模块继承的时候依赖失效的问题
第十三章 STL 之 set/ multiset
vim诡异的未知函数0
Mux256to1v,Hadd,Fadd
The study found that DNA nano device injection can be safely used for medical purposes