“今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛 )--E. DoveCCL and Resistance
题目描述:链接点此
这套题的github地址(里面包含了数据,题解,现场排名):点此
链接:https://www.nowcoder.com/acm/contest/104/D
来源:牛客网
题目描述
Do you remember Kanna-chan we met last year? She is so cute, and this year, she entered middle school, with Cirno. As we know, Cirno is bad at math, so she had trouble when studying physics.
Today, Kanna-chan's teacher is preparing for mid-term exam, one of the problem looks like follows:
Please calculate the equivalent resistance of the circuit below.
As Kanna-chan's teacher is too lazy, so he asked you for help, he will give you the answer of the problem, and your task is to generate a valid circuit satisfies that it's equivalent resistance equals to the answer.
输入描述:
Input contains one line with two integers, p and q, means the answer of the problem should be p/q, where ,
.
输出描述:
Output a circuit satisfy teacher's request. The first line of your input should be two integers, n and m, n is the number of nodes and m is the number of resistance you used. Where
Then m lines follows, each line contains three integers, ,which means that there is a wi-Ohm resistance connected between ui and vi,
, multiple resistances can be used between two nodes.
Then output two integers s, t, , means that the equivalent resistance between node s and node t equals to p/q.
输入例子:
22 9
输出例子:
3 4
1 2 2
2 3 1
2 3 1
2 3 4
1 3
-->
输入
22 9
输出
3 4
1 2 2
2 3 1
2 3 1
2 3 4
1 3
说明
/*
author:gsw
data:2018.04.30
link:https://www.nowcoder.com/acm/contest/104/B
accout:1697782237@qq.com(tonygsw)
*/
#define ll long long
#define IO ios::sync_with_stdio(false); #include<math.h>
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int m,n;
void dg(int x,int y,int k,int num)
{
if(y==)return;
n=max(num,n);
int a=x/y;
m++;
x=x-a*y;
if(x==){
m++;return;
}
int b=y/x;
m+=b;
int y1=y-b*x;
int x1=x;
dg(x1,y1,num,num+);
}
void print(int x,int y,int k,int num)
{
if(y==)return;
int a=x/y;
printf("%d %d %d\n",k,num,a);
x=x-a*y;
if(x==)
{
printf("%d %d %d\n",num,,);
return;
}
int b=y/x;
for(int i=;i<b;i++)
printf("%d %d %d\n",num,,);
int y1=y-b*x;
int x1=x;
print(x1,y1,num,num+);
}
int p,q; int main()
{
scanf("%d%d",&p,&q);
n=m=;
dg(p,q,,);
printf("%d %d\n",n,m);
print(p,q,,);
printf("1 2");
}
“今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛 )--E. DoveCCL and Resistance的更多相关文章
- “今日头条杯”首届湖北省大学程序设计竞赛--F. Flower Road
题目链接:点这 github链接:(包含数据和代码,题解):点这 链接:https://www.nowcoder.com/acm/contest/104/E来源:牛客网 题目描述 (受限于评测机,此题 ...
- A. Srdce and Triangle--“今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛)
如下图这是“今日头条杯”首届湖北省大学程序设计竞赛的第一题,作为赛后补题 题目描述:链接点此 这套题的github地址(里面包含了数据,题解,现场排名):点此 Let be a regualr tr ...
- I. Five Day Couple--“今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛)
题目描述:链接点此 这套题的github地址(里面包含了数据,题解,现场排名):点此 链接:https://www.nowcoder.com/acm/contest/104/H来源:牛客网 题目描述 ...
- D. Who killed Cock Robin--“今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛)
题目描述:链接点此 这套题的github地址(里面包含了数据,题解,现场排名):点此 题目描述 由于系统限制,C题无法在此评测,此题为现场赛的D题 Who killed Cock Robin? I, ...
- H. GSS and Simple Math Problem--“今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛)
题目描述:链接点此 这套题的github地址(里面包含了数据,题解,现场排名):点此 题目描述 Given n positive integers , your task is to calculat ...
- “东信杯”广西大学第一届程序设计竞赛(同步赛)H
链接:https://ac.nowcoder.com/acm/contest/283/H来源:牛客网 题目描述 由于临近广西大学建校90周年校庆,西大开始了喜闻乐见的校园修缮工程! 然后问题出现了,西 ...
- 陕西师范大学第七届程序设计竞赛网络同步赛 I 排队排队排队【数组任一位可以移动到队头,最少移动几次增序/数组指针操作】
链接:https://www.nowcoder.com/acm/contest/121/I来源:牛客网 题目描述 ACM竞赛队内要开运动会啦!!!! 竞赛队内的一群阳光乐观积极的队员们迅速的在操场上站 ...
- 西安电子科技大学第16届程序设计竞赛网络同步赛 G-小国的复仇
sb找规律. 分解因数. #include<bits/stdc++.h> #define LL long long #define fi first #define se second # ...
- 陕西师范大学第七届程序设计竞赛网络同步赛 J 黑猫的小老弟【数论/法拉数列/欧拉函数】
链接:https://www.nowcoder.com/acm/contest/121/J来源:牛客网 题目描述 大家知道,黑猫有很多的迷弟迷妹,当然也有相亲相爱的基友,这其中就有一些二五仔是黑猫的小 ...
随机推荐
- feign学习
feign集成了ribbon,只需要新建接口加注解即可 <!--feign相关--> <dependency> <groupId>org.springframewo ...
- legend2---17、legend2里面怎么面向对象
legend2---17.legend2里面怎么面向对象 一.总结 一句话总结: mvc本身挺优:本身mvc的开发模式,就算是面向过程下也还行,如果面向对象那就更加棒了 实体类无需属性:由于php的生 ...
- python主要探索函数
在数据分析中,Python的主要探索函数 Python中主要用于书探索的是pandas(数据分析)和matplotlib(数据可视化).其中pandas提供了大量的数据探索的工具与数据相关的函数,这些 ...
- find pattern
daniel@daniel-mint ~/msf/metasploit-framework/tools $ ruby pattern_create.rb 2000 Aa0Aa1Aa2Aa3Aa4Aa5 ...
- 记录以下mysql5.7在win使用Navicat无法链接的问题
1.前提 系统:win1o0 局域网服务器:ubuntu18.04 mysql版本:5.7 问题描述: 在ubuntu18.04下的shell 中使用mysql -uroot -p 是可以登陆的, ...
- Windows7下移植Qt4.8.4项目到QT5.2上时遇到的一些问题
最近在Windows7下将Qt4.8.4+MSVC2008的项目移植到QT5.2下时,遇到了一些小问题: 问题一:错误:C1083: 无法打开包括文件:"QApplication&q ...
- zabbix cpu监控介绍
一.CPU utilization 使用Zabbix查看CPU利用率,会有下面几个值: CPU idle time:空闲的cpu时间比[简称id]CPU user time:用户态使用的cpu时间比[ ...
- springboot 配置文件的加载顺序
springboot 配置文件的加载顺序1.在命令行中传入的参数.2. SPRING APPLICATION JSON中的属性. SPRING_APPLICATION—JSON是以JSON格式配置在系 ...
- android中的Serveice组件
创建 配置 Service: 1.定义一个继承了Service类的子类 2.在 AndroidManifest.xml清单文件中对开发的Service进行配置 Service和Activity很相似, ...
- 2018-8-10-win10-uwp-ApplicationView
title author date CreateTime categories win10 uwp ApplicationView lindexi 2018-08-10 19:16:53 +0800 ...