Codeforces Round #739 (Div. 3) ABCDEF1F2 解题思路

Codeforces Round #739 (Div. 3)

可能是一开始大佬都写F1去了,我在D写完后发现F过的人数比E多了好多(个位数与十位数),以为F1比较简单,就直接开F1了,但自己分类讨论老是考虑不完整,导致罚时直接垮掉

本来已经不想开E了,结果发现延长了15分钟,尝试着开一开,结果发现很水……现在在怀疑人生了嗯。

comp_status

UPD: F2已补


A - Dislike of Threes

思路

数据范围小( k ≤ 1000 k\le 1000 k1000),暴力预处理后输出即可。

代码

// URL: https://codeforces.com/contest/1560/problem/0
// Problem: A. Dislike of Threes
// Contest: Codeforces - Codeforces Round #739 (Div. 3)
// Time Limit: 1000 ms
// Memory Limit: 256 MB
// Author: StelaYuri
// 
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
#define closeSync ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define multiCase int T;cin>>T;for(int t=1;t<=T;t++)
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define repp(i,a,b) for(int i=(a);i<(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define perr(i,a,b) for(int i=(a);i>(b);i--)
#define all(a) (a).begin(),(a).end()
#define mst(a,b) memset(a,b,sizeof(a))
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=0x3f3f3f3f;
const ll LINF=0x3f3f3f3f3f3f3f3f;
const double eps=1e-12;
const double PI=acos(-1.0);
const ll mod=998244353;
const int dx[8]={
   0,1,0,-1,1,1,-1,-1},dy[8]={
   1,0,-1,0,1,-1,1,-1};
void debug(){
   cerr<<'\n';}template<typename T,typename... Args>void debug(T x,Args... args){
   cerr<<"[ "<<x<< " ] , ";debug(args...);}
mt19937 mt19937random(std::chrono::system_clock::now().time_since_epoch().count());
ll getRandom(ll l,ll r){
   return uniform_int_distribution<ll>(l,r)(mt19937random);}
ll gcd(ll a,ll b){
   return b==0?a:gcd(b,a%b);}
ll qmul(ll a,ll b){
   ll r=0;while(b){
   if(b&1)r=(r+a)%mod;b>>=1;a=(a+a)%mod;}return r;}
ll qpow(ll a,ll n){
   ll r=1;while(n){
   if(n&1)r=(r*a)%mod;n>>=1;a=(a*a)%mod;}return r;}
ll qpow(ll a,ll n,ll p){
   ll r=1;while(n){
   if(n&1)r=(r*a)%p;n>>=1;a=(a*a)%p;}return r;}

vector<int> vec;

int ck(int a)
{
   
    if(a%10==3||a%3==0)return 0;
    return 1;
}

void init()
{
   
    int p=1;
    while(vec.size()<1000)
    {
   
        if(ck(p))
            vec.pb(p);
        p++;
    }
}

void solve()
{
   
    int n;
    cin>>n;
    cout<<vec[n-1]<<'\n';
}
int main()
{
   
    closeSync;
    init();
    multiCase
    {
   
        solve();
    }
    return 0;
}

B - Who’s Opposite?

思路

根据题意, ∣ a − b ∣ × 2 |a-b|\times 2 ab×2可以得出这个环的点数 n n n

那么两点在环内相互对视的充分必要条件就是 a ± n 2 = b a\pm\frac n 2=b a±2n=b

最后只需要 c ≤ n c\le n cn,便能得出 c c c对视的点

代码

// URL: https://codeforces.com/contest/1560/problem/B
// Problem: B. Who's Opposite?
// Contest: Codeforces - Codeforces Round #739 (Div. 3)
// Time Limit: 1000 ms
// Memory Limit: 256 MB
// Author: StelaYuri
// 
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
#define closeSync ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define multiCase int T;cin>>T;for(int t=1;t<=T;t++)
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define repp(i,a,b) for(int i=(a);i<(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define perr(i,a,b) for(int i=(a);i>(b);i--)
#define all(a) (a).begin(),(a).end()
#define mst(a,b) memset(a,b,sizeof(a))
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=0x3f3f3f3f;
const ll LINF=0x3f3f3f3f3f3f3f3f;
const double eps=1e-12;
const double PI=acos(-1.0);
const ll mod=998244353;
const int dx[8]={
   0,1,0,-1,1,1,-1,-1},dy[8]={
   1,0,-1,0,1,-1,1,-1};
void debug(){
   cerr<<'\n';}template<typename T,typename... Args>void debug(T x,Args... args){
   cerr<<"[ "<<x<< " ] , ";debug(args...);}
mt19937 mt19937random(std::chrono::system_clock::now().time_since_epoch().count());
ll getRandom(ll l,ll r){
   return uniform_int_distribution<ll>(l,r)(mt19937random);}
ll gcd(ll a,ll b){
   return b==0?a:gcd(b,a%b);}
ll qmul(ll a,ll b){
   ll r=0;while(b){
   if(b&1)r=(r+a)%mod;b>>=1;a=(a+a)%mod;}return r;}
ll qpow(ll a,ll n){
   ll r=1;while(n){
   if(n&1)r=(r*a)%mod;n>>=1;a=(a*a)%mod;}return r;}
ll qpow(ll a,ll n,ll p){
   ll r=1;while(n){
   if(n&1)r=(r*a)%p;n>>=1;a=(a*a)%p;}return r;}



void solve()
{
   
    ll a,b,c;
    cin>>a>>b>>c;
    if(a>b)
        swap(a,b);
    ll n=(b-a)*2;
    if(b!=(a+n/2-1)%n+1||c>n)
    {
   
        cout<<"-1\n";
        return;
    }
    cout<<(c+n/2-1)%n+1<<'\n';
}
int main()
{
   
    closeSync;
    multiCase
    {
   
        solve();
    }
    return 0;
}

C - Infinity Table

思路

假设数字 1 1 1位于第 1 1 1层,数字 2 , 3 , 4 2,3,4 2,3,4位于第 2 2 2层,……

发现第 i i i层的数字个数为 i × 2 − 1 i\times 2-1 i×21

那么假设当前求的数字 k k k位于第 x + 1 x+1 x+1层,那么前 x x x层的总数便是 x 2 x^2 x2

由于数字 k k

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值