| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1519 人关注过本帖
标题:求求大佬们,帮我看一下这道题
只看楼主 加入收藏
Elean
Rank: 1
来 自:杭州
等 级:新手上路
帖 子:5
专家分:0
注 册:2021-10-7
结帖率:0
收藏
已结贴  问题点数:20 回复次数:2 
求求大佬们,帮我看一下这道题
Input
第一行输入一个T代表有T组测试数据。
每组测试数据输入n,m。

Output
每个人得到的金额。注意行末换行。
搜索更多相关主题的帖子: 测试 换行 输入 金额 数据 
2021-10-07 19:49
自由而无用
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:14
帖 子:61
专家分:1456
注 册:2021-8-9
收藏
得分:20 
hi, pretty girl, oh pls forgive my frivolous, I mean that good evening Miss Elean welcome to bccn->c_forum
-----------------------------------------------------------------------------------------------------------------
I recieved your request clearly, but I dont know how to deal with the digit (m & n)
so could you describe the math relation between m and n, for example: f(m,n) = ?
2021-10-07 20:05
Elean
Rank: 1
来 自:杭州
等 级:新手上路
帖 子:5
专家分:0
注 册:2021-10-7
收藏
得分:0 
回复 2楼 自由而无用
There are just some  lettere
input
1  10  3
output
3.33
2021-10-14 18:44
自由而无用
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:14
帖 子:61
专家分:1456
注 册:2021-8-9
收藏
得分:0 
wow, its an amazing puzzle, thank you for giving me this important clue
I will try it later, have a good evening, babe~
2021-10-14 19:09
自由而无用
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:14
帖 子:61
专家分:1456
注 册:2021-8-9
收藏
得分:0 
//online parser: https://www.bccn.net/run/
程序代码:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define TOKEN "X"
//end of TOKEN
#define Lovely_Elean_Formula  "1"TOKEN"10"TOKEN"3"TOKEN"3.33"TOKEN
//4 future doing
//#define Grandpa_V_Formula     "128"TOKEN"e"TOKEN"980"TOKEN"2116"TOKEN

static int rrem[32];
void* f_add(void *x, void *y, unsigned char type)
{
    void *ret = rrem;
    
#define V_CHR 0
#define V_INT 1
#define V_FLT 2
#define V_DBL 3
#define LOG_SYM(_s) putchar(_s);
#define LOG_SYM_ADD LOG_SYM('+')

    LOG_SYM_ADD;
    switch (type) {
#define ADD_S +
#define cast2type_add(_r, _x, _y, _t)   \
        *(_t *)(_r) = *(_t *)(_x) ADD_S *(_t *)(_y)
        case V_CHR: 
            cast2type_add(ret, x, y, char);
        break;
        case V_INT:
            cast2type_add(ret, x, y, int);
        break;
        case V_FLT:
            cast2type_add(ret, x, y, float);
        break;
        case V_DBL:
            cast2type_add(ret, x, y, double);
        break;
    }
    
    return ret;
}

void* f_sub(void *x, void *y, unsigned char type)
{
    void *ret = rrem;

#define LOG_SYM_SUB LOG_SYM('-')
    
    LOG_SYM_SUB;
    switch (type) {
#define SUB_S -
#define cast2type_sub(_r, _x, _y, _t)   \
        *(_t *)(_r) = *(_t *)(_x) SUB_S *(_t *)(_y)
        case V_CHR: 
            cast2type_sub(ret, x, y, char);
        break;
        case V_INT:
            cast2type_sub(ret, x, y, int);
        break;
        case V_FLT:
            cast2type_sub(ret, x, y, float);
        break;
        case V_DBL:
            cast2type_sub(ret, x, y, double);
        break;
    }
    
    return ret;
}

void* f_mul(void *x, void *y, unsigned char type)
{
    void *ret = rrem;

#define LOG_SYM_MUL LOG_SYM('*')
    
    LOG_SYM_MUL;
    switch (type) {
#define MUL_S *
#define cast2type_mul(_r, _x, _y, _t)   \
        *(_t *)(_r) = *(_t *)(_x) MUL_S *(_t *)(_y)
        case V_CHR: 
            cast2type_mul(ret, x, y, char);
        break;
        case V_INT:
            cast2type_mul(ret, x, y, int);
        break;
        case V_FLT:
            cast2type_mul(ret, x, y, float);
        break;
        case V_DBL:
            cast2type_mul(ret, x, y, double);
        break;
    }
    
    return ret;
}

void* f_div(void *x, void *y, unsigned char type)
{
    void *ret = rrem;

#define LOG_SYM_DIV LOG_SYM('/')
    
    LOG_SYM_DIV;    
    switch (type) {
#define DIV_S /
#define cast2type_div(_r, _x, _y, _t)   \
        *(_t *)(_r) = *(_t *)(_x) DIV_S *(_t *)(_y)
        case V_CHR: 
            cast2type_div(ret, x, y, char);
        break;
        case V_INT:
            cast2type_div(ret, x, y, int);
        break;
        case V_FLT:
            cast2type_div(ret, x, y, float);
        break;
        case V_DBL:
            cast2type_div(ret, x, y, double);
        break;
    }
    
    return ret;
}

unsigned char* parse_expr(unsigned char *expr, int *vpos)
{
    unsigned char *ret = (unsigned char *)rrem;

    while (expr) {
        *ret++ = *expr++;
        if ('X' == *expr) {
            //set tail
            *ret = 0;
            //return nwpos
            *vpos = ret - (unsigned char *)rrem + 1;
            return (unsigned char *)rrem;
        } 
    }
    
    return (unsigned char *)rrem;
}

typedef void* (*math_fund)(void*, void*, unsigned char);
static math_fund fund_tbl[4] = {
    f_add, f_sub, f_mul, f_div
};
static char optr_tbl[4] = {
    '+', '-', '*', '/'
};
enum Lv_Elean{EPA = 0, EPB, EPC};

int main(int argc, char *argv[]);
int Miss_Eleans_puzzle_game(double *op, double res)
{
    int i = 0;
    double v_exp;
#define F_TBL_LEN sizeof(fund_tbl) / sizeof(fund_tbl[0])
#define USR_SCOUT_DEPTH 10
    while (i++ < USR_SCOUT_DEPTH) {
#define fund_idx(_i) (((unsigned char *)main)[_i] % 4)
#define Lottery_A 39
#define Lottery_B 40
#define op_act_A  (i + Lottery_A)
#define op_act_B  (i + Lottery_B)
//#define PRINT_ON
#ifdef PRINT_ON
        printf("optr1: %c, optr2: %c\n", 
        optr_tbl[fund_idx(op_act_A)], optr_tbl[fund_idx(op_act_B)]);
#endif
        puts("-----brute force start----");
        v_exp = *(double *)fund_tbl[fund_idx(op_act_A)](&op[EPA], &op[EPB], V_DBL);
        printf("v_exp = %.2lf\n", v_exp);
        v_exp = *(double *)fund_tbl[fund_idx(op_act_B)](&v_exp, &op[EPC], V_DBL);
        printf("v_exp = %.2lf\n", v_exp);
#define DIS 0.03
#define is_match(_exp) (fabs(_exp) < DIS)
#ifdef PRINT_ON
        printf("i = %d, v_exp = %.10f\n", i, v_exp);
#endif
        is_match(v_exp - res) ? 
        puts("!!!!!!!Lottery Jackpot!!!!!!!") : puts("reward mismatch");
        puts("-----brute force over-----");
        puts("                          ");
    }
}

int main(int argc, char *argv[])
{
    int of, inc = 0;
    double op[3], res;

    op[EPA] = atof(parse_expr(Lovely_Elean_Formula, &of));
    inc += of;
    op[EPB] = atof(parse_expr(&Lovely_Elean_Formula[inc], &of));
    inc += of;
    op[EPC] = atof(parse_expr(&Lovely_Elean_Formula[inc], &of));
    inc += of;
    res = atof(parse_expr(&Lovely_Elean_Formula[inc], &of));
#ifdef PRINT_ON
    printf("EPA = %.2lf, EPB = %.2lf\n", op[EPA], op[EPB]);
    printf("EPC = %.2lf, res = %.2lf, of = %d\n", op[EPC], res, of);
#endif

    Miss_Eleans_puzzle_game(op, res);

    return 0;
}


output sample:
-----brute force start----
+v_exp = 11.00
+v_exp = 14.00
reward mismatch
-----brute force over-----
                          
-----brute force start----
+v_exp = 11.00
-v_exp = 8.00
reward mismatch
-----brute force over-----
                          
-----brute force start----
-v_exp = -9.00
*v_exp = -27.00
reward mismatch
-----brute force over-----
                          
-----brute force start----
*v_exp = 10.00
/v_exp = 3.33

!!!!!!!Lottery Jackpot!!!!!!!
-----brute force over-----
                          
-----brute force start----
/v_exp = 0.10
*v_exp = 0.30
reward mismatch
-----brute force over-----
                          
-----brute force start----
*v_exp = 10.00
-v_exp = 7.00
reward mismatch
-----brute force over-----
                          
-----brute force start----
-v_exp = -9.00
+v_exp = -6.00
reward mismatch
-----brute force over-----
                          
-----brute force start----
+v_exp = 11.00
+v_exp = 14.00
reward mismatch
-----brute force over-----
                          
-----brute force start----
+v_exp = 11.00
+v_exp = 14.00
reward mismatch
-----brute force over-----
                          
-----brute force start----
+v_exp = 11.00
/v_exp = 3.67
reward mismatch
-----brute force over-----
2021-10-15 09:34
Elean
Rank: 1
来 自:杭州
等 级:新手上路
帖 子:5
专家分:0
注 册:2021-10-7
收藏
得分:0 
👍👍👍👍👍👍
2021-10-16 17:21
自由而无用
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:14
帖 子:61
专家分:1456
注 册:2021-8-9
收藏
得分:0 
回复 6楼 Elean
oh, I m very happy that you like it~~
Have a nice weekend, angel
2021-10-16 17:43
快速回复:求求大佬们,帮我看一下这道题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.035119 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved