当前位置: 首页 > wzjs >正文

有做公司网站的吗青岛seo结算

有做公司网站的吗,青岛seo结算,家庭网络如何做网站服务器,小公司做网站目录 题目描述输入格式输出格式输入输出样例 #1输入 #1输出 #1 说明/提示题目思路AC 代码 题目描述 You have been offered to play a game. In this game, there are $ n $ possible outcomes, and for each of them, you must bet a certain integer amount of coins. In th…

目录

    • 题目描述
    • 输入格式
    • 输出格式
    • 输入输出样例 #1
      • 输入 #1
      • 输出 #1
    • 说明/提示
    • 题目思路
    • AC 代码

题目描述

You have been offered to play a game. In this game, there are $ n $ possible outcomes, and for each of them, you must bet a certain integer amount of coins. In the event that the $ i $ -th outcome turns out to be winning, you will receive back the amount of coins equal to your bet on that outcome, multiplied by $ k_i $ . Note that exactly one of the $ n $ outcomes will be winning.

Your task is to determine how to distribute the coins in such a way that you will come out ahead in the event of any winning outcome. More formally, the total amount of coins you bet on all outcomes must be strictly less than the number of coins received back for each possible winning outcome.

输入格式

Each test consists of multiple test cases. The first line contains a single integer $ t $ ( $ 1 \le t \le 10^4 $ ) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer $ n $ ( $ 1 \le n \le 50 $ ) — the number of outcomes.

The second line of each test case contains $ n $ integers $ k_1,k_2,\ldots,k_n $ ( $ 2 \le k_i \le 20 $ ) — the multiplier for the amount of coins if the $ i $ -th outcome turns out to be winning.

It is guaranteed that the sum of $ n $ over all test cases does not exceed $ 2 \cdot 10^5 $ .

输出格式

For each test case, output $ -1 $ if there is no way to distribute the coins as required. Otherwise, output $ n $ integers $ x_1, x_2,\ldots, x_n $ ( $ 1 \le x_i \le 10^{9} $ ) — your bets on the outcomes.

It can be shown that if a solution exists, there is always a solution that satisfies these constraints.

If there are multiple suitable solutions, output any of them.

输入输出样例 #1

输入 #1

6
3
3 2 7
2
3 3
5
5 5 5 5 5
6
7 9 3 17 9 13
3
6 3 2
5
9 4 6 8 3

输出 #1

27 41 12 
1 1 
-1
1989 1547 4641 819 1547 1071 
-1
8 18 12 9 24

说明/提示

In the first test case, the coins can be distributed as follows: $ 27 $ coins on the first outcome, $ 41 $ coins on the second outcome, $ 12 $ coins on the third outcome. Then the total amount of coins bet on all outcomes is $ 27 + 41 + 12 = 80 $ coins. If the first outcome turns out to be winning, you will receive back $ 3 \cdot 27 = 81 $ coins, if the second outcome turns out to be winning, you will receive back $ 2 \cdot 41 = 82 $ coins, if the third outcome turns out to be winning, you will receive back $ 7 \cdot 12 = 84 $ coins. All these values are strictly greater than $ 80 $ .

In the second test case, one way is to bet one coin on each of the outcomes.

题目思路

猜结论。

k 1 , k 2 , … , k n , k n k_1,k_2,\dots,k_n,k_n k1,k2,,kn,kn,求最小公倍数,设此值为 x x x,则累加 x x x 分别除以 k 1 , k 2 , … , k n k_1,k_2,\dots,k_n k1,k2,,kn 的和,如果此值大于 x x x,则无解。否则,给第每个位置分配 x k i \frac{x}{k_i} kix 数量的钱即可。

AC 代码

#include <bits/stdc++.h>
using namespace std;
long long a[55];
long long gcd(long long a,long long b){if(b == 0) return a;return gcd(b,a % b); 
}
long long lcm(long long a,long long b){return a * b / gcd(a,b);
} 
void solve(){int n;cin >> n;bool ok = 0;long long g = 0,sum = 0;cin >> a[1];g = a[1];for(int i = 2;i <= n;i++){cin >> a[i];g = lcm(g,a[i]);}for(int i = 1;i <= n;i++){sum += g / a[i];}for(int i = 1;i <= n;i++){if(g <= sum){cout << -1;ok = 1;break;}}if(!ok){for(int i = 1;i <= n;i++){cout << g / a[i] << " ";}}cout << endl;
}
int main(){int t;cin >> t; while(t--){solve();}return 0;
} 

创作不易,白嫖不好,各位的支持和认可,就是我创作的最大动力,如果喜欢我的文章,给个关注吧!

冰焰狼 | 文

如果本篇博客有任何错误,请批评指教,不胜感激 !

http://www.dtcms.com/wzjs/155048.html

相关文章:

  • 深圳教育软件app开发整站seo免费咨询
  • 传奇网站怎么做临沂做网络优化的公司
  • 茂名专业网站建设seo营销网站
  • 和韩国做贸易的网站sem是什么意思职业
  • 浪子做的阿哲喊麦网站多少梅花seo 快速排名软件
  • 查pv uv的网站厦门人才网个人登录
  • 怎么做百度搜到的网站免费的深圳企业黄页网
  • 市场营销策划案例经典大全做专业搜索引擎优化
  • 可以做网页的网站企业营销策划方案
  • 山西网站建设平台东莞seo排名优化
  • 镇江网站建设费用seo深圳培训班
  • 做qq图片的网站厦门seo排名优化公司
  • 淘宝网站如何做虚拟机广州专做优化的科技公司
  • 营销网站制作费用seo教程最新
  • 站酷设计网站官网入市场营销毕业后做什么工作
  • 做贸易上什么网站网络营销策划方案ppt
  • 北京做网站比较有名的公司品牌广告图片
  • 深圳龙岗布吉疫情最新消息哈尔滨百度网站快速优化
  • 新津城乡建设委员会网站网络营销课程心得体会
  • 哪个网站可以做论文简述搜索风云榜百度
  • wordpress二级菜单郑州seo网络推广
  • 青岛网签查询系统宁波网站建设优化企业
  • 创建网站主题在哪里网站发布
  • 什么软件 做短视频网站打字赚钱平台 学生一单一结
  • 汉滨区建设局网网站seo网络优化推广
  • wap网站自动公司seo是什么意思
  • 全球设计网站各网站收录
  • 医院网站做竞价需要注意广告法网站搜索关键词优化
  • 企业网站建站公司郑州如何看待百度竞价排名
  • 新闻发布网站建设实训小结百度官网认证