AtCoder Regular Contest 068--C--X: Yet Another Die Game(规律)--D - Card Eater(规律)

Time Limit: 2 sec / Memory Limit: 256 MB
Score :  points
Problem Statement Snuke has decided to play with a six-sided die. Each of its six sides shows an integer  through , and two numbers on opposite sides always add up to .
Snuke will rst put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:
Operation: Rotate the die  toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain  points where  is the number written in the side facing upward.
For example, let us consider the situation where the side showing  faces upward, the near side shows  and the right side shows , as illustrated in the gure. If the die is rotated toward the right as shown in the gure, the side showing  will face upward. Besides, the side showing  will face upward if the die is rotated toward the left, the side showing  will face upward if the die is rotated toward the front, and the side showing  will face upward if the die is rotated toward the back.
Find the minimum number of operation Snuke needs to perform in order to score at least  points in total.
Constraints
 is an integer.
Input The input is given from Standard Input in the following format:
 
Output Print the answer.
Sample Input 1

Sample Output 1

Sample Input 2
149696127901 
Sample Output 2
27217477801 

因为筛子一开始是任意一个面的!!

所以在5、6之间徘徊即可。不断来回。

#include <bits/stdc++.h>
#define LL long long
using namespace std;
const LL maxn = 100000+100;
int a[maxn];
int vis[maxn];
int main()
{
    LL n;
    cin>>n;
    LL ans=n/11*2;
    int mod=11;
    n%=mod;
    if(n>=1&&n<=6)ans++;
    else if(n>=7&&n<=10)ans+=2;
    cout<<ans;
}

D - Card Eater
Time Limit: 2 sec / Memory Limit: 256 MB
Score :  points
Problem Statement Snuke has decided to play a game using cards. He has a deck consisting of  cards. On the -th card from the top, an integer  is written.
He will perform the operation described below zero or more times, so that the values written on the remaining cards will be pairwise distinct. Find the maximum possible number of remaining cards. Here,  is odd, which guarantees that at least one card can be kept.
Operation: Take out three arbitrary cards from the deck. Among those three cards, eat two: one with the largest value, and another with the smallest value. Then, return the remaining one card to the deck.
Constraints
 is odd.
 is an integer.
Input The input is given from Standard Input in the following format:
       ...   
Output Print the answer.
Sample Input 1
5  1 2 1 3 7 
Sample Output 1

One optimal solution is to perform the operation once, taking out two cards with  and one card with . One card with  and another with  will be eaten, and the remaining card with  will be returned to deck. Then, the values written on the remaining cards in the deck will be pairwise distinct: ,  and .
Sample Input 2
15  1 3 5 2 1 3 2 8 8 6 2 6 11 1 1 
Sample Output 2

这个题要统计除1之外其他数的个数S,若S为奇数就输出S,否则输出S-1

#include <bits/stdc++.h>
#define LL long long
using namespace std;
const LL maxn = 100000+100;
int a[maxn];
int vis[maxn];
int main()
{
    //cout<<149696127901/6<<endl;
    int n;
    int ans=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(!vis[a[i]])
        vis[a[i]]++,ans++;
    }


    if(ans%2)printf("%d\n",ans);
    else printf("%d\n",ans-1);

}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值