CF-805C

C. Find Amir
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

A few years ago Sajjad left his school and register to another one due to security reasons. Now he wishes to find Amir, one of his schoolmates and good friends.

There are n schools numerated from 1 to n. One can travel between each pair of them, to do so, he needs to buy a ticket. The ticker between schools i and j costs  and can be used multiple times. Help Sajjad to find the minimum cost he needs to pay for tickets to visit all schools. He can start and finish in any school.

Input

The first line contains a single integer n (1 ≤ n ≤ 105) — the number of schools.

Output

Print single integer: the minimum cost of tickets needed to visit all schools.

Examples
input
2
output
0
input
10
output
4
Note

In the first example we can buy a ticket between the schools that costs .

 

 

 

题意:

共有n间学校,往返i,j两学校之间的票的价格为(i+j)%(n+1)。

求最小遍历所有学校的花费。

 

当n为偶数时,最小花费为n/2-1

1~n为0,n~2为1,2~n-1为0,以此类推。

 

当n为奇数时,需要连接中间的值,故再加一,为n/2.

 

附AC代码:

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 
 4 int main(){
 5     int n,ans=0;
 6     cin>>n;
 7     if(n%2){
 8         ans=n/2;
 9     }
10     else{
11         ans=n/2-1;
12     }
13     cout<<ans<<endl;
14     return 0;
15 }

 

转载于:https://www.cnblogs.com/Kiven5197/p/6815053.html

+ buildah bud --tls-verify=false --format=docker -t 11.11.157.164:31104/a6-uat/5715opss-front:v648_8195af64ad18fa4c4e5c3565358eac5fb13e461e -f Dockerfile . STEP 1: FROM 11.11.174.85:28086/cnpcrd/node:14.19.1-pnpm-nodesass AS builder Getting image source signatures Copying blob sha256:c398d8bd2d496fc1ba9d4658870242ce78aefe3041899476238df6cd427638f3 Copying blob sha256:7d66b83ec869a899bc8364af9c9eb0f1a5ba6907f699ef52f3182e19e2598924 Copying blob sha256:22360a9558f73f04bb5e4dbe6dbe1584cb913040ae66388a8db66fc2ed131002 Copying blob sha256:d88439e7b50a5f3923f67f432b6863c1e11adf4e45bf9740515d2cc01fd8e155 Copying blob sha256:f260dee23bc81622ef145aff36ad9816cca1c98bfa9361ad1bdf03c8975b104e Copying blob sha256:5f327ea23de9da0941be6aa9b1b0106716beba2b2221ccc2cf867db344fdc38b Copying blob sha256:c510cb256549cba034277b7ba3d45f821098be40e2d1ab716ebcbb2c82ad58e8 Copying blob sha256:39a6cf4e71acef62f9dc6133d8e2798afd190aa5d98df68c2c6a0853348c2a0b Copying blob sha256:5b88e0b6e02ac27e25195d6ef326172311c848a055cbe847de5e20547c526e55 Copying blob sha256:50868247d2ce4b9e47ed00d5c40c55746315be92ed203131e2139644a0cf22eb Copying blob sha256:e5e5c5e3f6d1226900e6c2d01182178f233df381354c7b91a233220d5d20d76a Copying blob sha256:db8034a611f27836dfac1f420b062134399233963dce16661cff75b190d7fa03 Copying blob sha256:88bc12f9a5d94abd68dd9f201555592838d5de85ab0b5cc8248199aa3f484a29 Copying blob sha256:80fbe3e8702a17df69ca8074656be9f7bd7fed87fd2d31dc7ec875b7249ec454 Copying blob sha256:8c1f72c02d3e7d7e3db33be2b133937124963fd2ac77215bd703129b4bae4c95 Copying blob sha256:009593723405a46968929d8221545f13495e3ff038367157a3597c2b8614d5ca Copying config sha256:2cb9f3e953292fdbce9015df8721a9f2336b49313ca036d96b52898a5d7af190 Writing manifest to image destination Storing signatures STEP 2: ARG profile STEP 3: ENV profile=${profile:-build} STEP 4: WORKDIR /usr/src/app STEP 5: COPY . ./ STEP 6: FROM 11.11.174.85:28086/cnpcrd/nginx-curl:v1.18.0 Getting image source signatures Copying blob sha256:d4e560a3091589fb95278a386add48626fbbe5bea3220576d6c4a838b4c65b24 Copying blob sha256:81bf9dd9cea603de3f08a37fb6f9156372709d0036479e6950b08b8b08dcf225 Copying blob sha256:47927ca6802f832d4000bfcde5939632a8ff52d6e4149187f198834556ee16e9 Copying blob sha256:4ede7ada96f6d9d2bc1f6ef734c74b5c0bc60a2f64e8c8d368055152d6dfe689 Copying blob sha256:f11c1adaa26e078479ccdd45312ea3b88476441b91be0ec898a7e07bfd05badc Copying blob sha256:9ac6875eca605a2e2f0a434d6a2f461356f32dae78fb3d4b9be23c2d02d46ac3 Copying blob sha256:e63758897ccc963cadd6f56a001bfcf5dc41dacce6a4e42ca1b3870f1cb91d14 Copying blob sha256:434abd9d8a2b02240f4daaeca44eb14e422ff394d4e1628d6d3208faece25d7c Copying blob sha256:bf49aa545a9f82a3131959a5232f51eee2b047fecaf6ff5a90410692be25b6e1 Copying blob sha256:d93ade5d972d5ede15f5d0fbc912f6f358b805c78c6ffd996a00e3e006aadd81 Copying blob sha256:c7bc6a87af944df6f159be206ce20093a771768e10f648de02b5aaae55bef62b Copying config sha256:75919dd59525e8fe57a70a5499ea69eee8c1eddaa61bac53e3c7212e5a232b82 Writing manifest to image destination Storing signatures STEP 7: COPY --from=builder /usr/src/app/dist /usr/share/nginx/html error building at STEP "COPY --from=builder /usr/src/app/dist /usr/share/nginx/html": no files found matching "/var/lib/containers/storage/overlay/bc9580993deabf5cc10eafbd76345ba0501fadfa1f733cf2fe0be5f44b80696d/merged/usr/src/app/dist": no such file or directory
03-19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值