71B - Progress Bar - CodeForces Solution


implementation math *1300

Please click on ads to support us..

Python Code:

from math import ceil, remainder

def capture_numbers():
    line = input()
    return [int(number) for number in line.split(' ')]

elements, max, percentage = capture_numbers()

step = 100 / elements

values = [0 for index in range(elements)]

fulls = int(percentage / step)

remaining = percentage - (fulls * step)

pwm = int(remaining * max / step)

for index in range(fulls):
    values[index] = max

if remaining != 0:
    values[fulls] = pwm


print(' '.join([str(value) for value in values]))

C++ Code:

#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<stack>
#include<iterator>
#include<deque>
#include<queue>
#include<unordered_set>
#include<set>
using namespace std;
using ll =  long long;
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define F first
#define S second
#define MANEX main
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vp = vector<pii>;
const ll INF = 1e18 + 10;
const int MAX = 1e5 + 10;

void solve() {
    int n, k, t;
    scanf("%d%d%d", &n, &k, &t);
    int canHave = (n * k * t) / 100;
    for(int i = 0; i < n; i++) {
        if(canHave > k) printf("%d ", k);
        else if(canHave > 0) printf("%d ", canHave);
        else printf("%d ", 0);
        canHave -= k;
    }
    printf("\n");
}  

int MANEX() {    
    solve();
}























Comments

Submit
0 Comments
More Questions

1722D - Line
1722C - Word Game
1722G - Even-Odd XOR
552E - Vanya and Brackets
933A - A Twisty Movement
1722F - L-shapes
1196B - Odd Sum Segments
1325D - Ehab the Xorcist
552B - Vanya and Books
1722E - Counting Rectangles
168A - Wizards and Demonstration
168B - Wizards and Minimal Spell
7A - Kalevitch and Chess
912B - New Year's Eve
1537C - Challenging Cliffs
879B - Table Tennis
1674E - Breaking the Wall
1282A - Temporarily unavailable
1366C - Palindromic Paths
336A - Vasily the Bear and Triangle
926A - 2-3-numbers
276D - Little Girl and Maximum XOR
1253C - Sweets Eating
1047A - Little C Loves 3 I
758D - Ability To Convert
733A - Grasshopper And the String
216A - Tiling with Hexagons
1351B - Square
1225A - Forgetting Things
1717A - Madoka and Strange Thoughts