cf1555A. PizzaForces
生活随笔
收集整理的這篇文章主要介紹了
cf1555A. PizzaForces
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
cf1555A. PizzaForces
A. PizzaForces
題意:
有三種披薩,第一種有六塊,需要花費15分鐘,第二種有8塊,需要花費20分鐘,第三問有10塊,需要花費25分鐘。
現在要吃x塊披薩,問最少時間花費?
題解:
不拿看出其實對于每一塊所花單位時間是一樣的,都是2.5,而基本單位是6,8,10,你會發現對于大于6的任意偶數他們都能組成,也就是對于10的任意偶數其實就是10*2.5,如果x是大于10的任意奇數,那就要多點一些湊成偶數。對于小于6的就要買一個6份套餐
代碼:
// Problem: A. PizzaForces // Contest: Codeforces - Educational Codeforces Round 112 (Rated for Div. 2) // URL: https://codeforces.com/contest/1555/problem/A // Memory Limit: 256 MB // Time Limit: 2000 ms // Data:2021-08-16 23:37:08 // By Jozky#include <bits/stdc++.h> #include <unordered_map> #define debug(a, b) printf("%s = %d\n", a, b); using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> PII; clock_t startTime, endTime; //Fe~Jozky const ll INF_ll= 1e18; const int INF_int= 0x3f3f3f3f; template <typename T> inline void read(T& x) {T f= 1;x= 0;char ch= getchar();while (0 == isdigit(ch)) {if (ch == '-')f= -1;ch= getchar();}while (0 != isdigit(ch))x= (x << 1) + (x << 3) + ch - '0', ch= getchar();x*= f; } template <typename T> inline void write(T x) {if (x < 0) {x= ~(x - 1);putchar('-');}if (x > 9)write(x / 10);putchar(x % 10 + '0'); } void rd_test() { #ifdef LOCALstartTime= clock();freopen("in.txt", "r", stdin); #endif } void Time_test() { #ifdef LOCALendTime= clock();printf("\nRun Time:%lfs\n", (double)(endTime - startTime) / CLOCKS_PER_SEC); #endif } int main() {//rd_test();/*6 8 1015 20 25*/int t;read(t);while (t--) {ll n;cin >> n;ll ans= max(6ll, n + 1) / 2 * 5;cout << ans << endl;}return 0;//Time_test(); }總結
以上是生活随笔為你收集整理的cf1555A. PizzaForces的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Educational Codeforc
- 下一篇: 国产统一操作系统(UOS)安装、体验