Sicily 4874. POGODAK

这篇博客介绍了一个关于立方体滚动路径的问题,玩家需要计算立方体滚动过程中在矩阵中留下的数字之和。通过理解和解决这个问题,读者可以深入学习路径查找和矩阵操作的技巧。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

4874. POGODAK

Constraints

Time Limit: 1 secs, Memory Limit: 256 MB

Description

Mirko doesn’t like Latin homeworks so he made a bet with Slavko. Loser will be writing homeworks for both of them the entire month. Mirko wants to win so he designed this problem they could have something to bet on.
At his desk he found a cube, with numbers 1 to 6 on its faces. Cube is shown on the picture. Additionally, sum of the numbers on opposing faces is equal to 7. That means that 6 is on the opposite face of 1, 5 on the opposite of 2 and 4 on the
opposite face of 3.

Mirko has put the cube in the upper left field of the matrix of R rows and C columns. The cube is initially oriented in a way that upper side is showing number 1, and side to the right number 3. Mirko now makes te following moves:
1. He is rolling the cube to the right, until it reaches the last column
2. Then he rolls it down (to the next row)
3. Now he rolls the cube to the left, until it reaches first column
4. Like in step 2, he rolls it down (to the next row)
Mirko is repeating these steps for as long as he can, i.e. as long as he can roll the cube in the next row. When a cube reaches some field, Mirko writes down the number on the top of the cube. In the end he sums all of the numbers he had written.
Mirko made a bet with Slavko that he could calculate that sum without error. Help Slavko verifying Mirko’s solution!
 

 

Input

First and only line of input contains two positive integers. R and C (1 ≤ R, C ≤ 100 000), matrix dimensions.

Output

First and only line of input should contain the sum described in the task.

Sample Input

sample input 1:
3 2
sample input 2:
3 4
sample input 3:
737 296

Sample Output

sample output 1:
19
sample output 2:
42
sample output 3:
763532

Hint

First sample description: numbers Mirko wrote down are:
1 4
1 5
3 5

Problem Source

CROATIAN OPEN COMPETITION IN INFORMATICS 2011.12

凶残模拟题

#include <stdio.h>

struct cube {
    int u;
    int d;
    int l;
    int r;
    int f;
    int b;
    cube(){};
    cube(int uu, int dd, int ll, int rr, int ff, int bb) {
        u = uu;
        d = dd;
        l = ll;
        r = rr;
        f = ff;
        b = bb;
    }
};

int main() {
    int row, col;
    cube c(1, 6, 4, 3, 5, 2);
    cube next_c;
    scanf("%d %d", &row, &col);
    bool is_go_right = true;
    long long int sum_all = 0;
    for (int i = 0; i < row; i++) {
        
        int sum_4 = c.l + c.r + c.u + c.d;
        int sum_row = (col / 4) * sum_4;
        if (col % 4 == 1) {
            sum_row += c.u;
            cube n_c(c.u, c.d, c.l, c.r, c.f, c.b);
            next_c = n_c;
        } else if (col % 4 == 2) {
            if (is_go_right) {
                sum_row += c.u + c.l;
                cube n_c(c.l, c.r, c.d, c.u, c.f, c.b);
                next_c = n_c;
            } else {
                sum_row += c.u + c.r;
                cube n_c(c.r, c.l, c.u, c.d, c.f, c.b);
                next_c = n_c;
            }
        } else if (col % 4 == 3) {
            if (is_go_right) {
                sum_row += c.u + c.l + c.d;
                cube n_c(c.d, c.u, c.r, c.l, c.f, c.b);
                next_c = n_c;
            } else {
                sum_row += c.u + c.r + c.d;
                cube n_c(c.d, c.u, c.r, c.l, c.f, c.b);
                next_c = n_c;
            }
        } else {
            cube n_c(c.l, c.r, c.u, c.d, c.f, c.b);
            next_c = n_c;
        }
        
        sum_all += sum_row;
        
        c.u = next_c.f;
        c.d = next_c.b;
        c.l = next_c.l;
        c.r = next_c.r;
        c.f = next_c.d;
        c.b = next_c.u;
        is_go_right = !is_go_right;
    }
    printf("%lld\n", sum_all);
    return 0;
}


基于Spring Boot搭建的一个多功能在线学习系统的实现细节。系统分为管理员和用户两个主要模块。管理员负责视频、文件和文章资料的管理以及系统运营维护;用户则可以进行视频播放、资料下载、参与学习论坛并享受个性化学习服务。文中重点探讨了文件下载的安全性和性能优化(如使用Resource对象避免内存溢出),积分排行榜的高效实现(采用Redis Sorted Set结构),敏感词过滤机制(利用DFA算法构建内存过滤树)以及视频播放的浏览器兼容性解决方案(通过FFmpeg调整MOOV原子位置)。此外,还提到了权限管理方面自定义动态加载器的应用,提高了系统的灵活性和易用性。 适合人群:对Spring Boot有一定了解,希望深入理解其实际应用的技术人员,尤其是从事在线教育平台开发的相关从业者。 使用场景及目标:适用于需要快速搭建稳定高效的在线学习平台的企业或团队。目标在于提供一套完整的解决方案,涵盖从资源管理到用户体验优化等多个方面,帮助开发者更好地理解和掌握Spring Boot框架的实际运用技巧。 其他说明:文中不仅提供了具体的代码示例和技术思路,还分享了许多实践经验教训,对于提高项目质量有着重要的指导意义。同时强调了安全性、性能优化等方面的重要性,确保系统能够应对大规模用户的并发访问需求。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值