atcoder365(A~E)

A.Leap Year

/*    ʕ•̀ ω • ʔ  *˘︶˘*).。.:*♡ (∗ᵒ̶̶̷̀ω˂̶́∗)੭₎₎̊₊♡ (⋈◍>◡<◍)       ʕ•̫͡• ʔ•̫͡•ཻʕ•̫͡•ʔ•͓͡•ʔ.•♫•♬ •♬•♫•.✿.。.:* ☆ .:**:.☆*.:。.✿  *★°*:.☆:*.°★*
●▂● ●0● ●︿● ●ω● ●﹏● ●△● ●▽●   ♡⃝ ʜᴇʟʟᴏ •ᴗ• ☽⋆
     ∩  ∩        ̋(๑˃́ꇴ˂̀๑)   ᐕ)⁾⁾  *:ஐ (๑´ᵕ`) ஐ:* *ଘ(੭*ˊᵕˋ)੭* (੭ˊᵕˋ)੭* ੈ✩˚
  >(>_<)<
    I   I
    I   I     ʕง•ᴥ•ʔง
    IU UI
   I     I          ꉂꉂ꒰•̤▿•̤*ૢ꒱
≧▂≦ ≧0≦ ≧︿≦ ≧ω≦ ≧﹏≦ ≧△≦ ꒰๑˃͈꒵˂͈๑꒱
☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫
(~o▔▽▔)~o o~(▔▽▔o~)   ‿︵‿︵‿︵୨˚̣̣̣͙୧ - - - -୨˚̣̣̣͙୧‿︵‿︵‿︵
  */
#include<bits/stdc++.h>
using namespace std;
#define lll __int128
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> PII;
const int mod=1e9+7;
inline ll read()
{
   ll x = 0, y = 1;
   char c = getchar();
   while (!isdigit(c))
   {
      if (c == '-')
         y = -1;
      c = getchar();
   }
   while (isdigit(c))
   {
      x = (x << 3) + (x << 1) + (c ^ 48);
      c = getchar();
   }
   return x *= y;
}
inline void write(ll x)
{
   if (x < 0)
      x = -x, putchar('-');
   ll sta[35], top = 0;
   do
      sta[top++] = x % 10, x /= 10;
   while (x);
   while (top)
      putchar(sta[--top] + '0');
}




void Miraitowa(){
   int n;
   cin >> n;
     if(n%4!=0)
        cout << 365 << endl;
        else if(n%4==0&&n%100!=0)
           cout << 366 << endl;
   else if(n%100==0&&n%400!=0)
      cout << 365 << endl;
      else if(n%400==0)
         cout << 366 << endl;
}


int main(){
 ios::sync_with_stdio(false);
 cin.tie(0),cout.tie(0);
   // int t;
   // cin>>t;
   // while(t--)
      Miraitowa();
     return 0;
};


B.Second Best

/*    ʕ•̀ ω • ʔ  *˘︶˘*).。.:*♡ (∗ᵒ̶̶̷̀ω˂̶́∗)੭₎₎̊₊♡ (⋈◍>◡<◍)       ʕ•̫͡• ʔ•̫͡•ཻʕ•̫͡•ʔ•͓͡•ʔ.•♫•♬ •♬•♫•.✿.。.:* ☆ .:**:.☆*.:。.✿  *★°*:.☆:*.°★*
●▂● ●0● ●︿● ●ω● ●﹏● ●△● ●▽●   ♡⃝ ʜᴇʟʟᴏ •ᴗ• ☽⋆
     ∩  ∩        ̋(๑˃́ꇴ˂̀๑)   ᐕ)⁾⁾  *:ஐ (๑´ᵕ`) ஐ:* *ଘ(੭*ˊᵕˋ)੭* (੭ˊᵕˋ)੭* ੈ✩˚
  >(>_<)<
    I   I
    I   I     ʕง•ᴥ•ʔง
    IU UI
   I     I          ꉂꉂ꒰•̤▿•̤*ૢ꒱
≧▂≦ ≧0≦ ≧︿≦ ≧ω≦ ≧﹏≦ ≧△≦ ꒰๑˃͈꒵˂͈๑꒱
☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫
(~o▔▽▔)~o o~(▔▽▔o~)   ‿︵‿︵‿︵୨˚̣̣̣͙୧ - - - -୨˚̣̣̣͙୧‿︵‿︵‿︵
  */
#include<bits/stdc++.h>
using namespace std;
#define lll __int128
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> PII;
const int mod=1e9+7;
inline ll read()
{
   ll x = 0, y = 1;
   char c = getchar();
   while (!isdigit(c))
   {
      if (c == '-')
         y = -1;
      c = getchar();
   }
   while (isdigit(c))
   {
      x = (x << 3) + (x << 1) + (c ^ 48);
      c = getchar();
   }
   return x *= y;
}
inline void write(ll x)
{
   if (x < 0)
      x = -x, putchar('-');
   ll sta[35], top = 0;
   do
      sta[top++] = x % 10, x /= 10;
   while (x);
   while (top)
      putchar(sta[--top] + '0');
}

const int N = 2e5 + 10;
PII a[N];

bool cmp(PII a,PII b){
   return a.first > b.first;
}

void Miraitowa(){
   int n;
   cin >> n;
   for (int i = 1; i <= n;i++)
      cin >> a[i].first, a[i].second = i;
   sort(a + 1, a + 1 + n, cmp);
   cout << a[2].second << endl;
}


int main(){
 ios::sync_with_stdio(false);
 cin.tie(0),cout.tie(0);
   // int t;
   // cin>>t;
   // while(t--)
      Miraitowa();
     return 0;
};


C.[Transportation Expenses](https://atcoder.jp/contests/abc364/tasks/abc364_c)

/*    ʕ•̀ ω • ʔ  *˘︶˘*).。.:*♡ (∗ᵒ̶̶̷̀ω˂̶́∗)੭₎₎̊₊♡ (⋈◍>◡<◍)       ʕ•̫͡• ʔ•̫͡•ཻʕ•̫͡•ʔ•͓͡•ʔ.•♫•♬ •♬•♫•.✿.。.:* ☆ .:**:.☆*.:。.✿  *★°*:.☆:*.°★*
●▂● ●0● ●︿● ●ω● ●﹏● ●△● ●▽●   ♡⃝ ʜᴇʟʟᴏ •ᴗ• ☽⋆
     ∩  ∩        ̋(๑˃́ꇴ˂̀๑)   ᐕ)⁾⁾  *:ஐ (๑´ᵕ`) ஐ:* *ଘ(੭*ˊᵕˋ)੭* (੭ˊᵕˋ)੭* ੈ✩˚
  >(>_<)<
    I   I
    I   I     ʕง•ᴥ•ʔง
    IU UI
   I     I          ꉂꉂ꒰•̤▿•̤*ૢ꒱
≧▂≦ ≧0≦ ≧︿≦ ≧ω≦ ≧﹏≦ ≧△≦ ꒰๑˃͈꒵˂͈๑꒱
☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫
(~o▔▽▔)~o o~(▔▽▔o~)   ‿︵‿︵‿︵୨˚̣̣̣͙୧ - - - -୨˚̣̣̣͙୧‿︵‿︵‿︵
  */
#include <bits/stdc++.h>
using namespace std;
#define lll __int128
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> PII;
const int mod = 1e9 + 7;
inline ll read()
{
   ll x = 0, y = 1;
   char c = getchar();
   while (!isdigit(c))
   {
      if (c == '-')
         y = -1;
      c = getchar();
   }
   while (isdigit(c))
   {
      x = (x << 3) + (x << 1) + (c ^ 48);
      c = getchar();
   }
   return x *= y;
}
inline void write(ll x)
{
   if (x < 0)
      x = -x, putchar('-');
   ll sta[35], top = 0;
   do
      sta[top++] = x % 10, x /= 10;
   while (x);
   while (top)
      putchar(sta[--top] + '0');
}

const int N = 3e5 + 10;
ll a[N];
ll n, k;

bool check(ll mid)
{
   ll w = 0;
   for (int i = 1; i <= n; i++)
      w += min(mid, a[i]);
   return w > k;
}

void Miraitowa()
{
   cin >> n >> k;
   ll s = 0;
   for (int i = 1; i <= n; i++)
      cin >> a[i], s += a[i];
   // cout << s << endl;
   if (s <= k)
   {
      cout << "infinite" << endl;
      return;
   }
   ll l = 0, r = 1e18;
   while (l < r)
   {
      ll mid = l + r >> 1;
      if (check(mid))
         r = mid;

      else
         l = mid + 1;
   }
   cout << l-1 << endl;
}

int main()
{
   ios::sync_with_stdio(false);
   cin.tie(0), cout.tie(0);
   // int t;
   // cin>>t;
   // while(t--)
   Miraitowa();
   return 0;
};

D.[AtCoder Janken 3](https://atcoder.jp/contests/abc364/tasks/abc364_c)

/*    ʕ•̀ ω • ʔ  *˘︶˘*).。.:*♡ (∗ᵒ̶̶̷̀ω˂̶́∗)੭₎₎̊₊♡ (⋈◍>◡<◍)       ʕ•̫͡• ʔ•̫͡•ཻʕ•̫͡•ʔ•͓͡•ʔ.•♫•♬ •♬•♫•.✿.。.:* ☆ .:**:.☆*.:。.✿  *★°*:.☆:*.°★*
●▂● ●0● ●︿● ●ω● ●﹏● ●△● ●▽●   ♡⃝ ʜᴇʟʟᴏ •ᴗ• ☽⋆
     ∩  ∩        ̋(๑˃́ꇴ˂̀๑)   ᐕ)⁾⁾  *:ஐ (๑´ᵕ`) ஐ:* *ଘ(੭*ˊᵕˋ)੭* (੭ˊᵕˋ)੭* ੈ✩˚
  >(>_<)<
    I   I
    I   I     ʕง•ᴥ•ʔง
    IU UI
   I     I          ꉂꉂ꒰•̤▿•̤*ૢ꒱
≧▂≦ ≧0≦ ≧︿≦ ≧ω≦ ≧﹏≦ ≧△≦ ꒰๑˃͈꒵˂͈๑꒱
☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫
(~o▔▽▔)~o o~(▔▽▔o~)   ‿︵‿︵‿︵୨˚̣̣̣͙୧ - - - -୨˚̣̣̣͙୧‿︵‿︵‿︵
  */
#include<bits/stdc++.h>
using namespace std;
#define lll __int128
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> PII;
const int mod=1e9+7;
inline ll read()
{
   ll x = 0, y = 1;
   char c = getchar();
   while (!isdigit(c))
   {
      if (c == '-')
         y = -1;
      c = getchar();
   }
   while (isdigit(c))
   {
      x = (x << 3) + (x << 1) + (c ^ 48);
      c = getchar();
   }
   return x *= y;
}
inline void write(ll x)
{
   if (x < 0)
      x = -x, putchar('-');
   ll sta[35], top = 0;
   do
      sta[top++] = x % 10, x /= 10;
   while (x);
   while (top)
      putchar(sta[--top] + '0');
}

const int N = 3e5 + 10;
int n;
string s;
int f[N][5];
void Miraitowa(){
  // R 石头  S剪刀  P 布
   cin >> n >> s;
   s = " " + s;
   for (int i = 1; i <= n;i++){
  
     if(s[i]=='R'){
        f[i][2] = max(f[i - 1][0], f[i - 1][1]) + 1;
        f[i][0] = max(f[i - 1][1], f[i - 1][2]);
     }
     else if (s[i] =='S'){
        f[i][0] = max(f[i - 1][1], f[i - 1][2]) + 1;
        f[i][1] = max(f[i - 1][0], f[i - 1][2]);
     }
     else{
        f[i][1] = max(f[i - 1][0], f[i - 1][2]) + 1;
        f[i][2] = max(f[i - 1][0], f[i - 1][1]);
     }
    }
    int res = max(f[n][0], f[n][1]);
    cout << max(res, f[n][2]) << endl;
}


int main(){
 ios::sync_with_stdio(false);
 cin.tie(0),cout.tie(0);
   // int t;
   // cin>>t;
   // while(t--)
      Miraitowa();
     return 0;
};


E.[ Xor Sigma Problem](https://atcoder.jp/contests/abc364/tasks/abc364_e)

/*    ʕ•̀ ω • ʔ  *˘︶˘*).。.:*♡ (∗ᵒ̶̶̷̀ω˂̶́∗)੭₎₎̊₊♡ (⋈◍>◡<◍)       ʕ•̫͡• ʔ•̫͡•ཻʕ•̫͡•ʔ•͓͡•ʔ.•♫•♬ •♬•♫•.✿.。.:* ☆ .:**:.☆*.:。.✿  *★°*:.☆:*.°★*
●▂● ●0● ●︿● ●ω● ●﹏● ●△● ●▽●   ♡⃝ ʜᴇʟʟᴏ •ᴗ• ☽⋆
     ∩  ∩        ̋(๑˃́ꇴ˂̀๑)   ᐕ)⁾⁾  *:ஐ (๑´ᵕ`) ஐ:* *ଘ(੭*ˊᵕˋ)੭* (੭ˊᵕˋ)੭* ੈ✩˚
  >(>_<)<
    I   I
    I   I     ʕง•ᴥ•ʔง
    IU UI
   I     I          ꉂꉂ꒰•̤▿•̤*ૢ꒱
≧▂≦ ≧0≦ ≧︿≦ ≧ω≦ ≧﹏≦ ≧△≦ ꒰๑˃͈꒵˂͈๑꒱
☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫☗♪叮☖叮♫ ☗铛♪ ☖♫
(~o▔▽▔)~o o~(▔▽▔o~)   ‿︵‿︵‿︵୨˚̣̣̣͙୧ - - - -୨˚̣̣̣͙୧‿︵‿︵‿︵
  */
#include <bits/stdc++.h>
using namespace std;
#define lll __int128
#define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> PII;
const int mod = 1e9 + 7;
inline ll read()
{
   ll x = 0, y = 1;
   char c = getchar();
   while (!isdigit(c))
   {
      if (c == '-')
         y = -1;
      c = getchar();
   }
   while (isdigit(c))
   {
      x = (x << 3) + (x << 1) + (c ^ 48);
      c = getchar();
   }
   return x *= y;
}
inline void write(ll x)
{
   if (x < 0)
      x = -x, putchar('-');
   ll sta[35], top = 0;
   do
      sta[top++] = x % 10, x /= 10;
   while (x);
   while (top)
      putchar(sta[--top] + '0');
}

const int N = 1e6 + 10;

ll n, a[N];
ll sum[N][40];

void Miraitowa()
{
   cin >> n;
   ll ans = 0;
   for (int i = 1; i <= n;i++)  cin >> a[i], ans += a[i];

   for (int i = 1; i <= n;i++)
      for (int j = 0; j < 40;j++)
         sum[i][j] = sum[i - 1][j] + (a[i] >> j & 1);

   ll res = 0;

   for (int j = 0; j < 40;j++){
      map<ll, ll> cnt;
      cnt[0]++;
      for (int i = 1; i <= n;i++){
         res += (1 << j) * cnt[(sum[i][j] & 1) ^ 1];
         cnt[sum[i][j] & 1]++;
      }
   }
   cout << res - ans << endl;
}

int main()
{
   ios::sync_with_stdio(false);
   cin.tie(0), cout.tie(0);
   // int t;
   // cin>>t;
   // while(t--)
   Miraitowa();
   return 0;
};

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值