头像

WangJY




离线:1天前


最近来访(2058)
用户头像
寄一心明月
用户头像
xujiangnan1014
用户头像
洛白さん
用户头像
深潜
用户头像
Link_Cut_Y
用户头像
MisakaMikoto
用户头像
真不会dp
用户头像
长夜未央
用户头像
Cold_heartless
用户头像
peach___
用户头像
Sufferingcreatinglife
用户头像
straySheep.
用户头像
徐胜虎
用户头像
我爱y总
用户头像
Likin
用户头像
闻天语
用户头像
一笙_
用户头像
云衣醉梦
用户头像
yxc的小迷妹
用户头像
AC_Boy


WangJY
22天前
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <inttypes.h>
#include <math.h>
#include <bit>
#include <random>
#include <complex>
#include <numbers>
using B = bool;
using S = int16_t;
using I = int32_t;
using L = long;
using LL = int64_t;
using SL = __int128_t;
using US = uint16_t;
using U = uint32_t;
using UL = unsigned long;
using ULL = uint64_t;
using USL = __uint128_t;
using F = float;
using D = double;
using LD = long double;
using C = std::complex<double>;
using VB = std::vector<B>;
using VS = std::vector<S>;
using VI = std::vector<I>;
using VL = std::vector<L>;
using VLL = std::vector<LL>;
using VSL = std::vector<__int128_t>;
using VUS = std::vector<US>;
using VU = std::vector<U>;
using VUL = std::vector<UL>;
using VULL = std::vector<ULL>;
using VUSL = std::vector<USL>;
using VF = std::vector<F>;
using VD = std::vector<D>;
using VLD = std::vector<LD>;
using VC = std::vector<C>;
#define IBUFSIZE 1000000
#define OBUFSIZE 1000000
#define INF ((((USL)1 << 126) - 1 << 1) + 1)
namespace random {std::random_device rd; std::mt19937_64 gen(rd());}
namespace IO
{
    const USL brt10 = ((USL)1 << 64) / 10;
    static char ibuf[IBUFSIZE], obuf[OBUFSIZE], *l = ibuf, *r = ibuf, *p = obuf;
    #define getchar() (l == r && (r = (l = ibuf) + fread(ibuf, 1, IBUFSIZE, stdin), l == r) ? EOF : *l ++ )
    #define flush() fwrite(obuf, 1, p - obuf, stdout), p = obuf
    void putchar(char x) {if (p - obuf == OBUFSIZE) flush(); *p ++ = x;}
    class Flusher {~Flusher() {flush();}} flusher;
    U read(char s[]) {memset(s, 0, sizeof s); char *p = s, c = getchar(); while (isspace(c)) c = getchar(); while (!isspace(c) && c ^ EOF) *p ++ = c, c = getchar(); return p - s;}
    template<class integer_class> void read(integer_class &x) {x = 0; char c = getchar(); I s = 1; while (isspace(c)) c = getchar(); if (c == '-') s = -1, c = getchar(); while (isdigit(c)) x = (x << 3) + (x << 1) + (x ^ 48), c = getchar(); x *= s;}
    template<class integer_class> void read(integer_class x[]) {for (integer_class &e : x) read(e);}
    template<class float_class> void read_float(float_class &x) {USL integer, decimal = 0; read(integer); char c = getchar(); x = integer; LD d = 1; while (isdigit(c)) d /= 10, x += (c ^ 48) * d;}
    template<class float_class> void read_float(float_class x[]) {for (float_class &e : x) read(e);}
    void write(char s[]) {U n = strlen(s); char *end = s + n; if (n > p - obuf) {memcpy(p, s, p - obuf), flush(), n -= p - obuf; while (n >= OBUFSIZE) fwrite(end - n, 1, OBUFSIZE, stdout), n -= OBUFSIZE; memcpy(p, end - n, n), p = obuf + n;}}
    template<class integer_class> void write(integer_class x) {if (x < 0) putchar('-'), x = -x; if (!x) return putchar('0'); static char t[40], p = 0; while (x) {t[p] = x - 10 * (brt10 * x >> 64), x /= 10; while (t[p] > 10) t[p] -= 10; t[p ++ ] ^= 48;} while (p) putchar(t[ -- p]);}
}
namespace math
{
    // template<class integer_class> integer_class lowbit(integer_class x) {return 1 << std::countr_zero(x);}
    template<class integer_class> integer_class lowbit(integer_class x) {return x & -x;}
    template<class integer_class, class mod_class> void qmod(integer_class x[], mod_class mod) {const USL brt = ((USL)1 << 64) / mod; for (integer_class &e : x) {e -= mod * (brt * e >> 64); while (e > mod) e -= mod;}}
    template<class numeric_class> I sign(numeric_class x, LD eps = 0) {return abs(x) > eps ? x > 0 ? 1 : -1 : 0;}
    template<class integer_class, class mod_class> mod_class pow(integer_class a, integer_class b, mod_class mod) {integer_class res = 1 % mod; while (b) {if (b & 1) res = res * a % mod; a = a * a % mod, b >>= 1;} return res;}
    template<class integer_class> integer_class phi(integer_class x) {integer_class res = x; for (U i{2}; i <= x / i; i ++ ) if (!(x % i)) {res /= i *= (i - 1); while (!(x % i)) x /= i;} if (x > 1) res /= x *= (x - 1); return res;}
    template<class integer_class> bool miller_rabin(integer_class x, U k) {std::uniform_int_distribution<integer_class> ud; if (x < 2 || !(x & 1)) return false; U s = std::countr_zero(x - 1), d = (x - 1) >> s; for (U i{}; i < k; i ++ ) {integer_class a = ud(random::gen), r = pow(a, d, x); for (U j{}; j < s; j ++ ) {integer_class l = pow(r, 2, x); if (l == 1 && r ^ 1 && r ^ x - 1) return false; r = l;} if (r ^ 1) return false;} return true;}
    template<class integer_class> std::pair<integer_class, integer_class> exgcd(integer_class a, integer_class b) {if (!b) return {1, 0}; auto p = exgcd(b, a % b); return {p.second, p.first - a / b * p.second};}
    template<class integer_class> std::tuple<std::vector<integer_class>, VB, std::vector<integer_class>, VI> sieve(integer_class n) {std::vector<integer_class> p, phi(n + 1); VB st(n + 1); VI mu(n + 1); st[0] = true, st[1] = true, mu[1] = 1; for (integer_class i{2}; i <= n; i ++ ) {if (!st[i]) p.push_back(i), phi[i] = i - 1, mu[i] = -1; for (integer_class j{}; p[j] * i <= n; j ++ ) {st[p[j] * i] = true; if (!(i % p[j])) {phi[p[j] * i] = phi[i] * p[j]; break;} phi[p[j] * i] = phi[i] * (p[j] - 1), mu[p[j] * i] = -mu[i];}} return {p, st, phi, mu};}
    void FFT(VC &f, I s) {U n = f.size(); if (n == 1) return ; VC t; for (C e : f) t.push_back(e); for (I i{}; i < n; i ++ ) f[i >> 1 + (i & 1 ? n >> 1 : 0)] = t[i]; VC a, b; for (I i{}; i < n >> 1; i ++ ) a.push_back(f[i]); for (I i{n >> 1}; i < n; i ++ ) b.push_back(f[i]); FFT(a, s), FFT(b, s); C c(1, 0), st(std::cos(2 * std::numbers::pi / n), std::sin(2 * std::numbers::pi * s / n)); for (I i{}; i < n >> 1; i ++ ) t[i] = a[i] + c * b[i], t[i + (n >> 1)] = a[i] - c * b[i], c *= st; f = t;}
}
template<const U base> class big_int
{
    VU x;
    public:
        big_int(VU x_) : x(x_) {}
        U size() {return x.size();}
        U operator [](U idx) {return x[x.size() - idx - 1];}
        big_int operator +(big_int y) {if (x.size() < y.x.size()) return y + big_int(x); VU res; U t{}; for (U i{}; i < x.size(); i ++ ) {t += x[i]; if (i < y.size()) t += y[i]; res.push_back(t % base), t /= base;} if (t) res.push_back(t); return big_int(res);}
        big_int operator -(big_int y) {if (x.size() < y.x.size()) return y + big_int(x); VU res; for (U i{}, t{}; i < x.size(); i ++ ) {t = x[i] - t; if (i < y.size()) t -= y[i]; res.push_back((t + base) % base), t = t < 0;} while (res.size() > 1 && !res.back()) res.pop_back(); return big_int(res);}
};


新鲜事 原文

WangJY
25天前
宣传比赛 https://www.luogu.com.cn/contest/109951


新鲜事 原文

WangJY
1个月前
周赛太毒了


活动打卡代码 AcWing 3431. skew数

WangJY
1个月前
while True:
    try: skew_binary = input()
    except EOFError: break
    print(sum(int(skew_binary[-i - 1]) * ((1 << i + 1) - 1) for i in range(len(skew_binary))))


活动打卡代码 AcWing 3446. 整数奇偶排序

WangJY
1个月前
l = list(map(int, input().split()))
print(*(sorted(filter(lambda x: x & 1, l), reverse=True) + sorted(filter(lambda x: not x & 1, l))))


活动打卡代码 AcWing 3473. 鸡兔同笼

WangJY
1个月前
for _ in range(int(input())):
    a = int(input())
    if a & 1: print(0, 0)
    else: print((a >> 2) + bool(a & 3), a >> 1)


活动打卡代码 AcWing 3451. 字符串排序II

WangJY
1个月前
while True:
    try: input_string = input()
    except EOFError: break
    sorted_array = sorted(filter(lambda character: character.isalpha(), input_string), key=str.lower) # 按转换成小写排序等于不区分大小写,sorted 是稳定的,满足规则 2
    alphabet_index = 0
    for character in input_string:
        if character.isalpha():
            print(end=sorted_array[alphabet_index])
            alphabet_index += 1
        else: print(end=character)
    print() # 别忘了最后要换行



WangJY
1个月前

题目描述

编写一个程序,将输入字符串中的字符按如下规则排序。

  • 规则 $1$:英文字母从 $A$ 到 $Z$ 排列,不区分大小写。如,输入:Type 输出:epTy
  • 规则 $2$:同一个英文字母的大小写同时存在时,按照输入顺序排列。如,输入:BabA 输出:aABb
  • 规则 $3$:非英文字母的其它字符保持原来的位置。如,输入:By?e 输出:Be?y

输入格式

输入包含多组测试数据。

每组数据占一行,包含一个字符串。

输出格式

每组数据输出一行结果,为按要求排序后的字符串。

数据范围

字符串长度不超过 $1000$,
每个输入最多包含 $100$ 组数据。

输入样例:

A Famous Saying: Much Ado About Nothing (2012/8).

输出样例:

A aaAAbc dFgghh: iimM nNn oooos Sttuuuy (2012/8).

算法

(模拟,计算量 $\approx6\times10^6$)

分行处理,每行把英文字母抠下来排序,再遍历字符串,遇到英文字母就把它替换成排序好的字符。

Python3 代码

while True:
    try: input_string = input()
    except EOFError: break
    sorted_array = sorted(filter(lambda character: character.isalpha(), input_string), key=str.lower) # 按转换成小写排序等于不区分大小写,sorted 是稳定的,满足规则 2
    alphabet_index = 0
    for character in input_string:
        if character.isalpha():
            print(end=sorted_array[alphabet_index])
            alphabet_index += 1
        else: print(end=character)
    print() # 别忘了最后要换行



WangJY
1个月前
print(int(bin(int(input()))[:1:-1], 2))


活动打卡代码 AcWing 3425. 小白鼠排队

WangJY
1个月前
d = {}
for _ in range(int(input())):
    l = input().split()
    d[int(l[0])] = l[1]
print('\n'.join(d[k] for k in sorted(d, reverse=True)))