头像

ljkstra




离线:18小时前


最近来访(514)
用户头像
种花家的兔兔
用户头像
AcWing2AK
用户头像
忘打周赛
用户头像
小镇刷题家
用户头像
Lin_LL
用户头像
丰起水
用户头像
114514恶臭
用户头像
宇宙有边
用户头像
itdef
用户头像
Andy2035
用户头像
KUZ
用户头像
一钧寒
用户头像
天蝎座的流星
用户头像
mwoier
用户头像
咳咳咳
用户头像
UKE
用户头像
Java不是瓜哇
用户头像
zxxxz___
用户头像
yyjjhh
用户头像
peter1111


ljkstra
2天前

下载地址
预览



分享 字体

ljkstra
3天前

给大家推荐一款英文字体Fira Code
下载地址https://www.fonts.net.cn/font-32128192175.html
效果(以前缀和为例):

关于如何把他放到你的编辑器里,大家可以自行百度。
关于
Sublime Text
VSCODE
DEV-C++




ljkstra
3天前

运行,显示:

terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc

代码

#include <bits/stdc++.h>
using namespace std;
int n;
int len;
vector<int> a;
vector<int> ans;
int g(int l) {
    int ans = 0;
    while (l) {
        l /= 10;
        ans ++;
    }
    return ans;
}
void dfs(int id, int t) {
    if (id >= len) {
        a.push_back(t);
        return;
    }
    dfs(id + 1, t * 10 + 1);
    dfs(id + 1, t * 10);
}
int main() {
    scanf("%d", &n);
    len = g(n);
    dfs(0, 0);
    for (int i = 0; i < (int)a.size(); ++i) {/*好像是这个循环的问题*/
        while (n >= a[i]) {
            n -= a[i];
            ans.push_back(a[i]);
        }
    }
    printf("%d\n", ans.size());
    for (int i = 0; i < (int)ans.size(); ++i)
        printf("%d ", ans[i]);
    return 0;
}

看起来似乎是$a_i$的锅。



新鲜事 原文

ljkstra
4天前
图片



ljkstra
4天前

给你一个区间$[l,r]$求从$l$~$r$每个数的阶乘分解质因数。输出和原版一样
有$T$组数据。
$1 \le T \le 10^6$
$1 \le L \le R \le 10^6$




ljkstra
4天前

blog

CODE:

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
const int MX = 23;
const long double eps = 1e-9;

int n,P;
int strength[MX];                                            
long double diff_lf,diff_rt,diff_lm,diff_rm;                   
long double lf,rt,lm,rm;                                     
long double d;                                                

bool comp(const int& i,const int& j){
    return i > j;
}

long long mypow(int a,int b){                                    
    long long r = 1,base = a;
    while (b){
        if (b & 1) r *= base;
        base *= base;
        b >>= 1;
    }
    return r;
}

inline long double sigma(long double diff,long double dist){
    long double sum = 0,idel = 100;
    for (int i = 1;i <= n;i++){
        long double score = 100 / (1 + exp(diff - dist * strength[i]));
        if (score < 1e-12){
            sum += (100.0 - idel) * log(100 / (100 - score));
        } else if (score >= 100){
            sum += (idel * log(100 / score));
        } else
        sum += (idel * log(100 / score)  +  (100.0 - idel) * log(100 / (100 - score)));
        idel -= d;
    }
    return sum;
}

void ans(long double val,int p){
    long long w = 1;                                          
    int ups = 0,used = 0;                           
    for (int i = 1;;i++){
        if (val / w*1.0 < 1) break;
        w *= 10,ups++;
    }
    long long res = (long long)(val * mypow(10,10 - ups)),highest = 1000000000;
    for (int i = 9;i >= 10 - p;i--){
        if (i == 9 - ups){
            if (i == 9) printf("0");
            printf(".");
        }
        cout<<(res / highest);
        res %= highest;
        used++;
        highest /= 10;
    }
    for (;used < ups;used++){
        printf("0");
    }
}

int main(){
    cin>>n>>P;
    d = 100.0 / (n - 1) * 1.0;
    for (int i = 1;i <= n;i++)
        cin>>strength[i];
    sort(strength + 1,strength + n + 1,comp);

    diff_lf = 0,diff_rt = 15;                      
    diff_lm = diff_lf + (diff_rt - diff_lf) / 3;
    diff_rm = diff_rt - (diff_rt - diff_lf) / 3;
    long double lf = 0,rt = 1,min_lm,min_rm,lm,rm; 

    while (diff_rt - diff_lf > eps){
        diff_lm = diff_lf + (diff_rt - diff_lf) / 3;
        diff_rm = diff_rt - (diff_rt - diff_lf) / 3;

        lf = 0,rt = 1;                           
        lm = lf + (rt - lf) / 3;
        rm = rt - (rt - lf) / 3;
        while (rt - lf > eps){ 
            lm = lf + (rt - lf) / 3;
            rm = rt - (rt - lf) / 3;
            if (sigma(diff_lm,lm) < sigma(diff_lm,rm))
                rt = rm;
            else
                lf = lm;
        }
        min_lm = sigma(diff_lm,lm);

        lf = 0,rt = 1,
        lm = lf + (rt - lf) / 3,
        rm = rt - (rt - lf) / 3;
        while (rt - lf > eps){
            lm = lf + (rt - lf) / 3;
            rm = rt - (rt - lf) / 3;
            if (sigma(diff_rm,lm) < sigma(diff_rm,rm))
                rt = rm;
            else
                lf = lm;
        }
        min_rm = sigma(diff_rm,lm);

        if (min_lm < min_rm)                                         
            diff_rt = diff_rm;
        else
            diff_lf = diff_lm;
    }
    ans(sigma(diff_lm,lm),P);
    return 0;
}



ljkstra
5天前
#define getchar() (tt == ss && (tt = (ss = In) + fread(In, 1, 1 << 20, stdin), ss == tt) ? EOF : *ss++)
char In[1 << 20], *ss=In, *tt=In;
namespace Fastio
{
    struct Reader
    {
        template <typename T> Reader& operator >> (T &x)
        {
            x = 0;
            short f = 1;
            char c = getchar();
            while (c < '0' || c > '9') { if (c == '-') f *= -1; c = getchar(); }
            while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
            x *= f;
            return *this;
        }
        Reader& operator >> (double &x)
        {
            x = 0;
            double t = 0;
            short f = 1, s = 0;
            char c = getchar();
            while ((c < '0' || c > '9') && c != '.') { if (c == '-') f *= -1; c = getchar(); }
            while (c >= '0' && c <= '9' && c != '.') x = x * 10 + (c ^ 48), c = getchar();
            if (c == '.') c = getchar();
            else { x *= f; return *this; }
            while (c >= '0' && c <= '9') t = t * 10 + (c ^ 48), s++, c = getchar();
            while (s--) t /= 10.0;
            x = (x + t) * f;
            return *this;
        }
        Reader& operator >> (long double &x)
        {
            x = 0;
            long double t = 0;
            short f = 1, s = 0;
            char c = getchar();
            while ((c < '0' || c > '9') && c != '.') { if (c == '-') f *= -1; c = getchar(); }
            while (c >= '0' && c <= '9' && c != '.') x = x * 10 + (c ^ 48), c = getchar();
            if (c == '.') c = getchar();
            else { x *= f; return *this; }
            while (c >= '0' && c <= '9') t = t * 10 + (c ^ 48), s++, c = getchar();
            while (s--) t /= 10.0;
            x = (x + t) * f;
            return *this;
        }
        Reader& operator >> (__float128 &x)
        {
            x = 0;
            __float128 t = 0;
            short f = 1, s = 0;
            char c = getchar();
            while ((c < '0' || c > '9') && c != '.') { if (c == '-') f *= -1; c = getchar(); }
            while (c >= '0' && c <= '9' && c != '.') x = x * 10 + (c ^ 48), c = getchar();
            if (c == '.') c = getchar();
            else { x *= f; return *this; }
            while (c >= '0' && c <= '9') t = t * 10 + (c ^ 48), s++, c = getchar();
            while (s--) t /= 10.0;
            x = (x + t) * f;
            return *this;
        }
        Reader& operator >> (char &c)
        {
            c = getchar();
            while (c == ' ' || c == '\n' || c == '\r') c = getchar();
            return *this;
        }
        Reader& operator >> (char *str)
        {
            int len = 0;
            char c = getchar();
            while (c == ' ' || c == '\n' || c == '\r') c = getchar();
            while (c != ' ' && c != '\n' && c != '\r') str[len++] = c, c = getchar();
            str[len] = '\0';
            return *this;
        }
        Reader& operator >> (string &str)
        {
            str.clear();
            char c = getchar();
            while (c == ' ' || c == '\n' || c == '\r') c = getchar();
            while (c != ' ' && c != '\n' && c != '\r') str.push_back(c), c = getchar();
            return *this;
        }
        Reader() {}
    } cin;
    const char endl = '\n';
    struct Writer
    {
        const int Setprecision = 6;
        typedef int mxdouble;
        template <typename T> Writer& operator << (T x)
        {
            if (x == 0) { putchar('0'); return *this; }
            if (x < 0) putchar('-'), x = -x;
            static short sta[40];
            short top = 0;
            while (x > 0) sta[++top] = x % 10, x /= 10;
            while (top > 0) putchar(sta[top] + '0'), top--;
            return *this;
        }
        Writer& operator << (double x)
        {
            if (x < 0) putchar('-'), x = -x;
            mxdouble _ = x;
            x -= (double)_;
            static short sta[40];
            short top = 0;
            while (_ > 0) sta[++top] = _ % 10, _ /= 10;
            if (top == 0) putchar('0');
            while (top > 0) putchar(sta[top] + '0'), top--;
            putchar('.');
            for (int i = 0; i < Setprecision; i++) x *= 10;
            _ = x;
            while (_ > 0) sta[++top] = _ % 10, _ /= 10;
            for (int i = 0; i < Setprecision - top; i++) putchar('0');
            while (top > 0) putchar(sta[top] + '0'), top--;
            return *this;
        }
        Writer& operator << (long double x)
        {
            if (x < 0) putchar('-'), x = -x;
            mxdouble _ = x;
            x -= (long double)_;
            static short sta[40];
            short top = 0;
            while (_ > 0) sta[++top] = _ % 10, _ /= 10;
            if (top == 0) putchar('0');
            while (top > 0) putchar(sta[top] + '0'), top--;
            putchar('.');
            for (int i = 0; i < Setprecision; i++) x *= 10;
            _ = x;
            while (_ > 0) sta[++top] = _ % 10, _ /= 10;
            for (int i = 0; i < Setprecision - top; i++) putchar('0');
            while (top > 0) putchar(sta[top] + '0'), top--;
            return *this;
        }
        Writer& operator << (__float128 x)
        {
            if (x < 0) putchar('-'), x = -x;
            mxdouble _ = x;
            x -= (__float128)_;
            static short sta[40];
            short top = 0;
            while (_ > 0) sta[++top] = _ % 10, _ /= 10;
            if (top == 0) putchar('0');
            while (top > 0) putchar(sta[top] + '0'), top--;
            putchar('.');
            for (int i = 0; i < Setprecision; i++) x *= 10;
            _ = x;
            while (_ > 0) sta[++top] = _ % 10, _ /= 10;
            for (int i = 0; i < Setprecision - top; i++) putchar('0');
            while (top > 0) putchar(sta[top] + '0'), top--;
            return *this;
        }
        Writer& operator << (char c) { putchar(c); return *this; }
        Writer& operator << (char *str)
        {
            int cur = 0;
            while (str[cur]) putchar(str[cur++]);
            return *this;
        }
        Writer& operator << (const char *str)
        {
            int cur = 0;
            while (str[cur]) putchar(str[cur++]);
            return *this;
        }
        Writer& operator << (string str)
        {
            int st = 0, ed = str.size();
            while (st < ed) putchar(str[st++]);
            return *this;
        }
        Writer() {}
    } cout;
}
using namespace Fastio;
#define cin Fastio::cin
#define cout Fastio::cout
#define endl Fastio::endl

使用方法和cin,cout一样,在本地使用时最后要加上Ctrl+z
当然,如果觉得麻烦可以去掉第一行和第二行,就不用Ctrl+z了
支持__int128__float128以及string



新鲜事 原文

ljkstra
5天前
刚刚看到有人F12,我也来一个。
图片



ljkstra
6天前

按下空格即可生效:

#include<stdio.h>
#include<windows.h>
int main()
{
    while(1)
    {
        if(GetAsyncKeyState(VK_SPACE))
        {
            while(1)
            {
                mouse_event(MOUSEEVENTF_LEFTDOWN|MOUSEEVENTF_LEFTUP,0,0,0,0);
                Sleep(10);
                if(GetAsyncKeyState(VK_ESCAPE))return 0; 
            }
        }
    }
    return 0;
}



ljkstra
6天前