4道拼夕夕算法题,没得100分的,确定不啃[阿里云算法笔试合集]?

论坛 期权论坛     
选择匿名的用户   2021-5-30 01:56   107   0
<p>废话不多说,现在我给你4道拼多多的笔试算法题,你觉得你可以得多少分?</p>
<p><img alt="" height="584" src="https://beijingoptbbs.oss-cn-beijing.aliyuncs.com/cs/5606289-6b3d782d4c4ea0a43d4a4da1ec3f7c55.png" width="889"></p>
<p> </p>
<p>不管会不会,请继续看文末的[阿里云算法笔试合集],意外从朋友那里嫖的,这是一本能“在线”编程的程序员面试宝典,分享给有需要的朋友,直接<strong><a href="https://docs.qq.com/doc/DVmx5TmxlaXZsSnZL">点这</a></strong>可白嫖</p>
<h1>第一题:按题意模拟,注意第N次到的话特判,否则只能过96%</h1>
<pre class="blockcode"><code>#include &lt;bits/stdc&#43;&#43;.h&gt; using namespace std;using LL &#61; long long;
int k, n;int x;signed main() {  // freopen(&#34;in&#34;, &#34;r&#34;, stdin);
  // freopen(&#34;out&#34;, &#34;w&#34;, stdout);
  while (~scanf(&#34;%d%d&#34;, &amp;k, &amp;n)) {    int cur &#61; 0, cnt &#61; 0;    int ok &#61; 0;    for (int i &#61; 1; i &lt;&#61; n; i&#43;&#43;) {      scanf(&#34;%d&#34;, &amp;x);      if (ok) continue;      if (cur &#43; x &#61;&#61; k) {        if(n !&#61; i) ok &#61; 1;
        cur &#43;&#61; x;
      } else if (cur &#43; x &gt; k) {
        cnt&#43;&#43;;
        cur &#61; k - (cur &#43; x - k);
      } else {
        cur &#43;&#61; x;
      }
    }    if (ok || k &#61;&#61; 0) {      printf(&#34;paradox\n&#34;);
    } else {      printf(&#34;%d %d\n&#34;, k - cur, cnt);
    }
  }  return 0;
}</code></pre>
<h1>第二题:我是枚举了24种同构&#43;并查集做的,一定有聪明的小朋友写出了预处理</h1>
<pre class="blockcode"><code>#include &lt;bits/stdc&#43;&#43;.h&gt;using namespace std;using LL &#61; long long;#define A 1#define B 2#define C 3#define D 4#define E 5#define F 6const int maxn &#61; 1010;int n;int dice[maxn][7];int pre[maxn];int find(int x) {  return x &#61;&#61; pre[x] ? x : pre[x] &#61; find(pre[x]);
}void unite(int x, int y) {
  x &#61; find(x); y &#61; find(y);
  pre[x] &#61; y;
}int check(int x, int y) {  if (dice[x][1]&#61;&#61;dice[y][A]&amp;&amp;dice[x][2]&#61;&#61;dice[y][B]&amp;&amp;dice[x][3]&#61;&#61;dice[y][C]&amp;&amp;dice[x][4]&#61;&#61;dice[y][D]&amp;&amp;dice[x][5]&#61;&#61;dice[y][E]&amp;&amp;dice[x][6]&#61;&#61;dice[y][F]) return 1;  if (dice[x][1]&#61;&#61;dice[y][C]&amp;&amp;dice[x][2]&#61;&#61;dice[y][D]&amp;&amp;dice[x][3]&#61;&#61;dice[y][B]&amp;&amp;dice[x][4]&#61;&#61;dice[y][A]&amp;&amp;dice[x][5]&#61;&#61;dice[y][E]&amp;&amp;dice[x][6]&#61;&#61;dice[y][F]) return 1;  if (dice[x][1]&#61;&#61;dice[y][B]&amp;&amp;dice[x][2]&#61;&#61;dice[y][A]&amp;&amp;dice[x][3]&#61;&#61;dice[y][D]&amp;&amp;dice[x][4]&#61;&#61;dice[y][C]&amp;&amp;dice[x][5]&#61;&#61;dice[y][E]&amp;&amp;dice[x][6]&#61;&#61;dice[y][F]) return 1;  if (dice[x][1]&#61;&#61;dice[y][D]&amp;&amp;dice[x][2]&#61;&#61;dice[y][C]&amp;&amp;dice[x][3]&#61;&#61;dice[y][A]&amp;&amp;dice[x][4]&#61;&#61;dice[y][B]&amp;&amp;dice[x][5]&#61;&#61;dice[y][E]&amp;&amp;dice[x][6]&#61;&#61;dice[y][F]) return 1;  if (dice[x][1]&#61;&#61;dice[y][A]&amp;&amp;dice[x][2]&#61;&#61;dice[y][B]&amp;&amp;dice[x][3]&#61;&#61;dice[y][D]&amp;&amp;dice[x][4]&#61;&#61;dice[y][C]&amp;&amp;dice[x][5]&#61;&#61;dice[y][F]&amp;&amp;dice[x][6]&#61;&#61;dice[y][E]) return 1;  if (dice[x][1]&#61;&#61;dice[y][C]&amp;&amp;dice[x][2]&#61;&#61;dice[y][D]&amp;&amp;dice[x][3]&#61;&#61;dice[y][A]&amp;&amp;dice[x][4]&#61;&#61;dice[y][B]&amp;&amp;dice[x][5]&#61;&#61;dice[y][F]&amp;&amp;dice[x][6]&#61;&#61;dice[y][E]) return 1;  if (dice[x][1]&#61;&#61;dice[y][B]&amp;&amp;dice[x][2]&#61;&#61;dice[y][A]&amp;&amp;dice[x][3]&#61;&#61;dice[y][C]&amp;&amp;dice[x][4]&#61;&#61;dice[y][D]&amp;&amp;dice[x][5]&#61;&#61;dice[y][F]&amp;&amp;dice[x][6]&#61;&#61;dice[y][E]) return 1;  if (dice[x][1]&#61;&#61;dice[y][D]&amp;&amp;dice[x][2]&#61;&#61;dice[y][C]&amp;&amp;dice[x][3]&#61;&#61;dice[y][B]&amp;&amp;dice[x][4]&#61;&#61;dice[y][A]&amp;&amp;dice[x][5]&#61;&#61;dice[y][F]&amp;&amp;dice[x][6]&#61;&#61;dice[y][E]) return 1;  if (dice[x][1]&#61;&#61;dice[y][A]&amp;&amp;dice[x][2]&#61;&#61;dice[y][B]&amp;&amp;dice[x][3]&#61;&#61;dice[y][F]&amp;&amp;dice[x][4]&#61;&#61;dice[y][E]&amp;&amp;dice[x][5]&#61;&#61;dice[y][C]&amp;&amp;dice[x][6]&#61;&#61;dice[y][D]) return 1;  if (dice[x][1]&#61;&#61;dice[y][F]&amp;&amp;dice[x][2]&#61;&#61;dice[y][E]&amp;&amp;dice[x][3]&#61;&#61;dice[y][B]&amp;&amp;dice[x][4]&#61;&#61;dice[y][A]&amp;&amp;dice[x][5]&#61;&#61;dice[y][C]&amp;&amp;dice[x][6]&#61;&#61;dice[y][D]) return 1;  if (dice[x][1]&#61;&#61;dice[y][B]&amp;&amp;dice[x][2]&#61;&#61;dice[y][A]&amp;&amp;dice[x][3]&#61;&#61;dice[y][E]&amp;&amp;dice[x][4]&#61;&#61;dice[y][F]&amp;&amp;dice[x][5]&#61;&#61;dice[y][C]&amp;&amp;dice[x][6]&#61;&#61;dice[y][D]) return 1;  if (dice[x][1]&#61;&#61;dice[y][E]&amp;&amp;dice[x][2]&#61;&#61;dice[y][F]&amp;&amp;dice[x][3]&#61;&#61;dice[y][A]&amp;&amp;dice[x][4]&#61;&#61;dice[y][B]&amp;&amp;dice[x][5]&#61;&#61;dice[y][C]&amp;&amp;dice[x][6]&#61;&#61;dice[y][D]) return 1;  if (dice[x][1]&#61;&#61;dice[y][A]&amp;&amp;dice[x][2]&#61;&#61;dice[y][B]&amp;&amp;dice[x][3]&#61;&#61;dice[y][E]&amp;&amp;dice[x][4]&#61;&#61;dice[y][F]&amp;&amp;dice[x][5]&#61;&#61;dice[y][D]&amp;&amp;dice[x][6]&#61;&#61;dice[y][C]) return 1;  if (dice[x][1]&#61;&#61;dice[y][E]&amp;&amp;dice[x][2]&#61;&#61;dice[y][F]&amp;&amp;dice[x][3]&#61;&#61;dice[y][B]&amp;&amp;dice[x][4]&#61;&#61;dice[y][A]&amp;&amp;dice[x][5
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP